From: sera@... (Francis Hwang) Date: 2004-09-20T23:54:39+09:00 Subject: Passing in CGI parameters to an .rhtml file with StringIO#instance_eval There's probably something really simple I'm missing here, but: I'm trying to run an Eruby file from inside a Ruby class, and find a general way to pass in the CGI parameters, but I'm stumbling on that. I figured that for a get, CGI parameters are effectively passed in via $stdin, so I tried this: compiler = ERuby::Compiler.new() src = nil File.open( @rhtml ) { |file| src = compiler.compile_file( file ) } arg_strings = args.collect { |pair| "#{ pair.first.to_s }=#{ pair.last.to_s }" } arg_str = arg_strings.join( '&' ) stringio_in = StringIO.new( arg_str ) orig_stdin = $stdin $stdin = StringIO.new( arg_str ) begin stringio = StringIO.new stringio.instance_eval src stringio.string ensure $stdin = orig_stdin end But that doesn't seem to work. Suggestions? Francis