Module: Miam::TemplateHelper

Included in:
DSL::Context, DSL::Context::Group, DSL::Context::ManagedPolicy, DSL::Context::Role, DSL::Context::User
Defined in:
lib/miam/template_helper.rb

Instance Method Summary collapse

Instance Method Details

#contextObject



16
17
18
# File 'lib/miam/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/miam/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