Class: Chaplin::Parser::Pages

Inherits:
Struct
  • Object
show all
Defined in:
lib/chaplin/parser/pages.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#layout_nameObject

Returns the value of attribute layout_name

Returns:

  • (Object)

    the current value of layout_name



8
9
10
# File 'lib/chaplin/parser/pages.rb', line 8

def layout_name
  @layout_name
end

#pages_dataObject

Returns the value of attribute pages_data

Returns:

  • (Object)

    the current value of pages_data



8
9
10
# File 'lib/chaplin/parser/pages.rb', line 8

def pages_data
  @pages_data
end

#project_pathObject

Returns the value of attribute project_path

Returns:

  • (Object)

    the current value of 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

#loadObject



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] = embed_in_layout(page)
  end
end