Module: Kelbim::TemplateHelper

Instance Method Summary collapse

Instance Method Details

#contextObject



16
17
18
# File 'lib/kelbim/template_helper.rb', line 16

def context
  @context
end

#include_template(template_name, context = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/kelbim/template_helper.rb', line 3

def include_template(template_name, context = {})
  tmplt = @context.templates[template_name.to_s]

  unless tmplt
    raise "Template `#{template_name}` is not defined"
  end

  context_orig = @context
  @context = @context.merge(context)
  instance_eval(&tmplt)
  @context = context_orig
end