I am using OpenStructs and ERB for template generation. In this simple
example, ruby 1.8.6 runs this fine:
require erb
require ostruct
puts ERB.new(%=foo%, 0, %).result(OpenStruct.new({ :foo = bar
}).send(:binding))
However, it generates the following error when I run this in IronRuby
I notice that in your example, you don't declare the local variable foo
anywhere:
If I run it verbatim, both MRI and IronRuby fail with undefined method foo
(and fair enough, foo isn't defined).
When I declare foo as a local variable, both MRI and IronRuby work fine
for me.
I am trying to send the binding of the OpenStruct object not the binding of
main. I have been using this with MRI 1.8.6 for some time and works fine.
From: ironruby-core-boun...@rubyforge.org
[mailto:ironruby-core-boun...@rubyforge.org] On Behalf Of Orion Edwards
Sent: Tuesday, June 19, 2012
Ahh I see.
I don't have a copy of 1.8.6 handy to test on, but this definitely fails
for MRI 1.9.
It seems like getting the binding of an ostruct in 1.9 doesn't work for
evaluating local variables. Perhaps they changed ostruct?
Here's what happens for me:
irb(main):020:0 ostruct =