Class: Bridgetown::LayoutReader

Inherits:
Object
  • Object
show all
Defined in:
bridgetown-core/lib/bridgetown-core/readers/layout_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ LayoutReader

Returns a new instance of LayoutReader.



7
8
9
10
# File 'bridgetown-core/lib/bridgetown-core/readers/layout_reader.rb', line 7

def initialize(site)
  @site = site
  @layouts = HashWithDotAccess::Hash.new
end

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



5
6
7
# File 'bridgetown-core/lib/bridgetown-core/readers/layout_reader.rb', line 5

def site
  @site
end

Instance Method Details

#layout_directoryObject



28
29
30
# File 'bridgetown-core/lib/bridgetown-core/readers/layout_reader.rb', line 28

def layout_directory
  @layout_directory ||= site.in_source_dir(site.config["layouts_dir"])
end

#readObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'bridgetown-core/lib/bridgetown-core/readers/layout_reader.rb', line 12

def read
  layout_entries.each do |layout_file|
    @layouts[layout_name(layout_file)] =
      Layout.new(site, layout_directory, layout_file)
  end

  site.config.source_manifests.filter_map(&:layouts).each do |plugin_layouts|
    layout_entries(plugin_layouts).each do |layout_file|
      @layouts[layout_name(layout_file)] ||=
        Layout.new(site, plugin_layouts, layout_file, from_plugin: true)
    end
  end

  @layouts
end