Class: Dimples::Template
- Inherits:
-
Object
- Object
- Dimples::Template
- Defined in:
- lib/dimples/template.rb
Overview
A single template used when rendering pages, posts and other templates.
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
Constructor Details
#initialize(site, path) ⇒ Template
Returns a new instance of Template.
10 11 12 13 14 15 16 |
# File 'lib/dimples/template.rb', line 10 def initialize(site, path) @site = site @path = path data = File.read(path) @contents, = FrontMatter.parse(data) end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
7 8 9 |
# File 'lib/dimples/template.rb', line 7 def contents @contents end |
#metadata ⇒ Object
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/dimples/template.rb', line 8 def end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/dimples/template.rb', line 6 def path @path end |
Instance Method Details
#render(context = {}, body = nil) ⇒ Object
18 19 20 21 |
# File 'lib/dimples/template.rb', line 18 def render(context = {}, body = nil) context[:template] ||= Hashie::Mash.new() renderer.render(context, body) end |