From: Sean O'Halpin Date: 2005-11-20T01:20:33+09:00 Subject: Re: generic, non web based templating engine? On 11/18/05, Michael Campbell wrote: > > I like the erb syntax, and would love to have the full power of ruby > inside the template, if possible. Something like OGNL is for java... > If you like erb, why not use it? ;) Here's an example to get you started: require 'erb' def do_erb(str, erb_binding, trim_mode = '%') str.untaint erb = ERB.new(str, $SAFE, trim_mode) erb.result(erb_binding) end class Foo attr_accessor :greeting end foo = Foo.new foo.greeting = "Hello" template = < from simple erb template % 1.upto(10) do |i| item <%= i %> % end EOT puts do_erb(template, foo.instance_eval{binding}) --- OUTPUT --- Hello from simple erb template item 1 item 2 item 3 Regards, Sean