Module: GoodData::Helpers::ErbHelper

Defined in:
lib/gooddata/helpers/erb_helper.rb

Class Method Summary collapse

Class Method Details

.template_file(path, params) ⇒ Object



17
18
19
# File 'lib/gooddata/helpers/erb_helper.rb', line 17

def template_file(path, params)
  template_string(File.read(path), params)
end

.template_string(template, params = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/gooddata/helpers/erb_helper.rb', line 7

def template_string(template, params = {})
  b = binding

  params.each do |k, v|
    b.local_variable_set(k, v)
  end

  ERB.new(template).result(b)
end