Class: Handlebars::CompiledTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/handlebars.rb

Instance Method Summary collapse

Constructor Details

#initialize(context, template) ⇒ CompiledTemplate

Returns a new instance of CompiledTemplate.



19
20
21
# File 'lib/handlebars.rb', line 19

def initialize(context, template)
  @context, @template = context, template
end

Instance Method Details

#call(data) ⇒ Object



23
24
25
26
27
# File 'lib/handlebars.rb', line 23

def call(data)
  json = MultiJson.encode(data)
  @context['template'] = @template
  @context.eval "template(#{json})"
end