Archive for the 'erb' Category

03
Sep
11

erb templates


Example of using erb templates in a normal script:


require "erb"
require "ostruct"

tstr  = "This the first <%= what %>"
tmpl = ERB.new(tstr)
puts tmpl.result(OpenStruct.new(:what => "value").send(:binding))

ERB uses a binding, and in this case, we’re using OpenStruct’s.




Blog Stats

  • 222,663 hits