Class: JekyllPageBoilerplate::Page
- Inherits:
-
Object
- Object
- JekyllPageBoilerplate::Page
- Defined in:
- lib/jekyll_page_boilerplate/page.rb
Constant Summary collapse
- BOILERPLATES_PATH =
'_boilerplates'- READ_CONFIG_REGEX =
/[\r\n\s]{0,}^_boilerplate:(\s*^[\t ]{1,2}.+$)+[\r\s\n]{0,}(?![^\r\s\n])/- READ_FILE_REGEX =
/^-{3}\s*^(?<head>[\s\S]*)^-{3}\s^(?<body>[\s\S]*)/- TAGS_REGEX =
/\{{2}\s{0,}boilerplate\.([^\{\}\.\s]+)\s{0,}\}{2}/
Instance Attribute Summary collapse
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(boilerplate, custom_args, options) ⇒ Page
constructor
A new instance of Page.
Constructor Details
#initialize(boilerplate, custom_args, options) ⇒ Page
Returns a new instance of Page.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jekyll_page_boilerplate/page.rb', line 23 def initialize boilerplate, custom_args, plate_path = get_boilerplate_path(boilerplate) abort_unless_file_exists( plate_path ) parsed_file = {} File.open(plate_path, 'r') do |file| parsed_file = file.read.match(READ_FILE_REGEX).named_captures end = JekyllPageBoilerplate::Tags.new( defaults(plate_path), get_header_config(parsed_file['head']), , parse_custom_args(custom_args) ) [:file] = '{{ date }}-{{ slug }}{{ suffix }}' if . .fill(:slug, :file, safe: true) .fill(:path, safe: false) @head = get_head(parsed_file['head']) @body = parsed_file['body'] end |
Instance Attribute Details
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
15 16 17 |
# File 'lib/jekyll_page_boilerplate/page.rb', line 15 def end |
Class Method Details
.run(boilerplate, custom_args, options) ⇒ Object
17 18 19 20 21 |
# File 'lib/jekyll_page_boilerplate/page.rb', line 17 def self.run boilerplate, custom_args, page = self.new(boilerplate, custom_args, ) page.create return "Created "+ File.join(page.['path'], page.['file']) end |
Instance Method Details
#create ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/jekyll_page_boilerplate/page.rb', line 46 def create FileUtils.mkdir_p(.path) scan_template :@body scan_template :@head create_new_page end |