From: Joseph McDonald Date: 2000-12-15T08:40:19+09:00 Subject: [ruby-talk:7263] more on the template system Here is a rough outline of what I am thinking of: snippet1 = <<'EOF' def output puts "I am snippet1 var is: #{var}" puts var2.inspect puts "joe" end EOF snippet2 = <<'EOF' def output puts "I am snippet2 var is: #{var}" puts var2.inspect end EOF class JotsOutput end class Jots def initialize(s) @parsed = s @t = JotsOutput.new end def execute if(!@t.respond_to?("output")) # first time through... puts "doing eval..." JotsOutput.module_eval(@parsed) end begin @t.output() rescue NameError puts "namerror" end end def setvars # set vars in JotsOutput namespace... end end t1 = Jots.new(snippet1) t2 = Jots.new(snippet2) # want it to call eval again... t1.execute t2.execute t1.execute prints: doing eval... namerror namerror namerror one problem I have is that I would like to do an eval for each instance of the Jots object. Not just once like I am doing now. I tried to replace: JotsOutput.module_eval(@parsed) with: @t1.module_eval(@parsed) and @t1.eval(@parsed) but neither of those worked. Can you see what I am getting at? I'd like to have a different "output" function for each JotsOutput object that each Jots object contains. Is this possible? If not, any work arounds come to mind? thanks, -joe