Class: Baha::PreBuild::Module::Template::ErbBinding

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/baha/pre_build/template.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash, config) ⇒ ErbBinding

Returns a new instance of ErbBinding.



10
11
12
13
# File 'lib/baha/pre_build/template.rb', line 10

def initialize(hash,config)
  super(hash)
  @config = config
end

Instance Method Details

#get_bindingObject



14
15
16
# File 'lib/baha/pre_build/template.rb', line 14

def get_binding
  binding()
end

#render(file) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/baha/pre_build/template.rb', line 17

def render(file)
  rfile = @config.resolve_file(file) || @config.resolve_file(File.join(name,file))
  if rfile
    ERB.new(File.read(rfile),0,'-').result(binding)
  else
    raise ArgumentError.new("Template unable to render #{file}: not found")
  end
end