Class: Dimples::Template
- Inherits:
-
Object
- Object
- Dimples::Template
- Includes:
- Frontable
- Defined in:
- lib/dimples/template.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(site, path) ⇒ Template
constructor
A new instance of Template.
- #render(context = {}, body = nil) ⇒ Object
Methods included from Frontable
Constructor Details
#initialize(site, path) ⇒ Template
Returns a new instance of Template.
11 12 13 14 15 |
# File 'lib/dimples/template.rb', line 11 def initialize(site, path) @site = site @path = path @contents, @metadata = read_with_front_matter(path) end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
8 9 10 |
# File 'lib/dimples/template.rb', line 8 def contents @contents end |
#metadata ⇒ Object
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/dimples/template.rb', line 9 def @metadata end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/dimples/template.rb', line 7 def path @path end |
Instance Method Details
#render(context = {}, body = nil) ⇒ Object
17 18 19 20 |
# File 'lib/dimples/template.rb', line 17 def render(context = {}, body = nil) context[:template] ||= Hashie::Mash.new(@metadata) renderer.render(context, body) end |