Class: Alephant::Renderer::Engine::Mustache

Inherits:
Object
  • Object
show all
Defined in:
lib/alephant/renderer/engine/mustache.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_path, namespace, partials_path = nil) ⇒ Mustache

Returns a new instance of Mustache.



7
8
9
10
11
# File 'lib/alephant/renderer/engine/mustache.rb', line 7

def initialize(base_path, namespace, partials_path = nil)
  @namespace = namespace
  @base_path = base_path
  @partial_path = partials_path || default_shared_partial_path
end

Instance Method Details

#default_shared_partial_pathObject



18
19
20
# File 'lib/alephant/renderer/engine/mustache.rb', line 18

def default_shared_partial_path
  File.join(@base_path, '../lib/templates')
end

#render(data) ⇒ Object



13
14
15
16
# File 'lib/alephant/renderer/engine/mustache.rb', line 13

def render(data)
  mustache.template_path = @partial_path
  mustache.render(template, data)
end

#template_pathObject



22
23
24
# File 'lib/alephant/renderer/engine/mustache.rb', line 22

def template_path
  File.join(@base_path, 'templates')
end