This isn''t for rails specifically.. I''m trying to do some ERB
operations..
I''m trying to do some template parsing in a class.. here is my class:
require ''erb''
class TemplateParser
def TemplateParser.parse(template, params)
params.each do |k,v|
self.instance_variable_set(:"@#{k}",v)
end
template_content = ''''
File.open(template, "r") do |f|
while line = f.gets
template_content << line
end
end
e = ERB.new(template_content, 0, "%<>")
e.result
end
end
so in my template.. if I have a variable called "revisions". and it is
set in the params[:revisions] hash. It defines an instance on the class
called revisions, but ERB is not seeing that.. What can I do get around
this?
Thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---