class Alephant::Renderer::Engine::Mustache

Public Class Methods

new(base_path, namespace, partials_path = nil) click to toggle source
# 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

Public Instance Methods

default_shared_partial_path() click to toggle source
# File lib/alephant/renderer/engine/mustache.rb, line 18
def default_shared_partial_path
  File.join(@base_path, '../lib/templates')
end
render(data) click to toggle source
# File lib/alephant/renderer/engine/mustache.rb, line 13
def render(data)
  mustache.template_path = @partial_path
  mustache.render(template, data)
end
template_path() click to toggle source
# File lib/alephant/renderer/engine/mustache.rb, line 22
def template_path
  File.join(@base_path, 'templates')
end

Private Instance Methods

mustache() click to toggle source
# File lib/alephant/renderer/engine/mustache.rb, line 36
def mustache
  ::Mustache
end
template() click to toggle source
# File lib/alephant/renderer/engine/mustache.rb, line 32
def template
  @template_string ||= File.open(template_file).read
end
template_file() click to toggle source
# File lib/alephant/renderer/engine/mustache.rb, line 28
def template_file
  File.join(template_path, "#{@namespace}.#{::Mustache.template_extension}")
end