Class: Jekyll::Layout
- Inherits:
-
Object
- Object
- Jekyll::Layout
- Includes:
- Convertible
- Defined in:
- lib/jekyll/layout.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#data ⇒ Object
Returns the value of attribute data.
-
#ext ⇒ Object
Returns the value of attribute ext.
Instance Method Summary collapse
-
#add_layout(layouts, site_payload) ⇒ Object
Add any necessary layouts to this post
layouts
is a Hash of => “layout”site_payload
is the site payload hash. -
#initialize(base, name) ⇒ Layout
constructor
Initialize a new Layout.
-
#process(name) ⇒ Object
Extract information from the layout filename
name
is the String filename of the layout file.
Methods included from Convertible
#determine_content_type, #do_layout, #read_yaml, #to_s, #transform
Constructor Details
#initialize(base, name) ⇒ Layout
Initialize a new Layout.
+base+ is the String path to the <source>
+name+ is the String filename of the post file
Returns <Page>
14 15 16 17 18 19 20 21 22 |
# File 'lib/jekyll/layout.rb', line 14 def initialize(base, name) @base = base @name = name self.data = {} self.process(name) self.read_yaml(base, name) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/jekyll/layout.rb', line 7 def content @content end |
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/jekyll/layout.rb', line 7 def data @data end |
#ext ⇒ Object
Returns the value of attribute ext.
6 7 8 |
# File 'lib/jekyll/layout.rb', line 6 def ext @ext end |
Instance Method Details
#add_layout(layouts, site_payload) ⇒ Object
Add any necessary layouts to this post
+layouts+ is a Hash of {"name" => "layout"}
+site_payload+ is the site payload hash
Returns nothing
37 38 39 40 41 42 43 44 45 |
# File 'lib/jekyll/layout.rb', line 37 def add_layout(layouts, site_payload) payload = {"page" => self.data}.deep_merge(site_payload) self.content = Liquid::Template.parse(self.content).render(payload, [Jekyll::Filters]) layout = layouts[self.data["layout"]] || self.content payload = {"content" => self.content, "page" => self.data} self.content = Liquid::Template.parse(layout).render(payload, [Jekyll::Filters]) end |
#process(name) ⇒ Object
Extract information from the layout filename
+name+ is the String filename of the layout file
Returns nothing
28 29 30 |
# File 'lib/jekyll/layout.rb', line 28 def process(name) self.ext = File.extname(name) end |