Class: Dimples::Template

Inherits:
Object
  • Object
show all
Includes:
Frontable
Defined in:
lib/dimples/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Frontable

#read_with_front_matter

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

#contentsObject

Returns the value of attribute contents.



8
9
10
# File 'lib/dimples/template.rb', line 8

def contents
  @contents
end

#metadataObject

Returns the value of attribute metadata.



9
10
11
# File 'lib/dimples/template.rb', line 9

def 
  @metadata
end

#pathObject

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