F
Francis Hwang
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
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