Class: Chaplin::Parser::Pages
- Inherits:
-
Struct
- Object
- Struct
- Chaplin::Parser::Pages
- Defined in:
- lib/chaplin/parser/pages.rb
Instance Attribute Summary collapse
-
#layout_name ⇒ Object
Returns the value of attribute layout_name.
-
#pages_data ⇒ Object
Returns the value of attribute pages_data.
-
#project_path ⇒ Object
Returns the value of attribute project_path.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#layout_name ⇒ Object
Returns the value of attribute layout_name
7 8 9 |
# File 'lib/chaplin/parser/pages.rb', line 7 def layout_name @layout_name end |
#pages_data ⇒ Object
Returns the value of attribute pages_data
7 8 9 |
# File 'lib/chaplin/parser/pages.rb', line 7 def pages_data @pages_data end |
#project_path ⇒ Object
Returns the value of attribute project_path
7 8 9 |
# File 'lib/chaplin/parser/pages.rb', line 7 def project_path @project_path end |
Class Method Details
.load(pages_data, project_path, layout_name = nil) ⇒ Object
9 10 11 12 13 |
# File 'lib/chaplin/parser/pages.rb', line 9 def self.load(pages_data, project_path, layout_name = nil) new(pages_data, project_path, layout_name).tap do |pages| pages.load end end |
Instance Method Details
#[](page_name) ⇒ Object
28 29 30 |
# File 'lib/chaplin/parser/pages.rb', line 28 def [](page_name) @pages[page_name] || build_templated_page(page_name) end |
#load ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/chaplin/parser/pages.rb', line 15 def load @pages = {} pages_data.each do |template_name, raw_data_hash| @pages[template_name] = build_page(template_name, raw_data_hash) end return unless layout_name @pages = @pages.each_with_object({}) do |(page_name, page), pages_in_layout| pages_in_layout[page_name] = (page) end end |