From: Paul Brannan Date: 2002-02-21T03:33:29+09:00 Subject: Re: including files in eruby On Thu, Feb 21, 2002 at 03:26:44AM +0900, Alan Chen wrote: > I've just been require'ing the files as normal ruby code. I've been > prototyping an ruby based web application and use requires to separate > the ruby application logic from the eruby presentation code. I don't know if this is the "best" way, but I've been doing something like this: myfile.cgi: File.open('myfile.rhtml') do |input| eval <<-END MY_TEMPLATE = proc { |var1, var2, var3| #{ERuby::Compiler.new.compile_string(input.read())} } END end MY_TEMPLATE.call(1, 2, 3) myfile.rhtml: <%= var1 %>
<%= var2 %>
<%= var3 %>
Paul