From: James Masters Date: 2009-09-27T07:16:41+09:00 Subject: Re: ERB: import function Jano Svitok wrote: > def import path > ERB.new(File.read(path), nil, nil, '_x_').result() > end If you are planning on recursive inclusion, then you might want to add some kind of a unique number to the output variable to avoid collision: class ERB @output_num = 0 class << self attr_accessor :output_num end end def import path n = ERB.output_num += 1 ERB.new(File.read(path), nil, nil, '_x_'+n.to_s).result() end One thing to also be careful with is that when a syntax error occurs, the file name is not printed in the exception message. It might be useful to rescue the syntax error exception and include the file name in the exception stack. -- Posted via http://www.ruby-forum.com/.