A
Andrew Chen
Hi,
I use the instance_eval to merge template file and parameter files.
require 'erb'
instance_eval(File.read('param.txt'))
puts ERB.new(File.read("tmpl.txt")).result(binding)
puts name
template.rb:7: undefined method `name' for main:Object (NoMethodError)
Where is the variable "name" set to? How to access it?
It must be somewhere, since it is used in the tmpl.txt file.
Is there any "magic" namespace in Ruby?
Thanks
~Andrew Chen
I use the instance_eval to merge template file and parameter files.
cat param.txt name="John"
cat tmpl.txt
#!/usr/bin/env rubymy name is: said:cat template.rb
require 'erb'
instance_eval(File.read('param.txt'))
puts ERB.new(File.read("tmpl.txt")).result(binding)
puts name
my name is: Johntemplate.rb
template.rb:7: undefined method `name' for main:Object (NoMethodError)
Where is the variable "name" set to? How to access it?
It must be somewhere, since it is used in the tmpl.txt file.
Is there any "magic" namespace in Ruby?
Thanks
~Andrew Chen