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
8 9 10 |
# File 'lib/chaplin/parser/pages.rb', line 8 def layout_name @layout_name end |
#pages_data ⇒ Object
Returns the value of attribute pages_data
8 9 10 |
# File 'lib/chaplin/parser/pages.rb', line 8 def pages_data @pages_data end |
#project_path ⇒ Object
Returns the value of attribute project_path
8 9 10 |
# File 'lib/chaplin/parser/pages.rb', line 8 def project_path @project_path end |
Class Method Details
.load(pages_data, project_path, layout_name = nil) ⇒ Object
10 11 12 13 14 |
# File 'lib/chaplin/parser/pages.rb', line 10 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
29 30 31 |
# File 'lib/chaplin/parser/pages.rb', line 29 def [](page_name) @pages[page_name] || build_templated_page(page_name) end |
#load ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chaplin/parser/pages.rb', line 16 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 |