Class: Handlebars::CompiledTemplate
- Inherits:
-
Object
- Object
- Handlebars::CompiledTemplate
- Defined in:
- lib/handlebars.rb
Instance Method Summary collapse
- #call(data) ⇒ Object
-
#initialize(context, template) ⇒ CompiledTemplate
constructor
A new instance of CompiledTemplate.
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 |