[Ironruby-core] Problem with using OpenStruct and ERB

Nathan Standiford nstandif at live.com
Tue Jun 19 22:55:10 UTC 2012

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-bounces at rubyforge.org
[mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Orion Edwards
Sent: Tuesday, June 19, 2012 2:23 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Problem with using OpenStruct and ERB


I notice that in your example, you don't declare the local variable foo

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


Orion Edwards | Technical Leader 
PHONE +64 7 838 9800 | FAX +64 7 838 9801 | 
EMAIL orion.edwards at gallagher.co | WEB  <http://www.gallagher.co/>

From:        Nathan Standiford <nstandif at live.com> 
To:        <ironruby-core at rubyforge.org> 
Date:        20/06/2012 04:55 a.m. 
Subject:        [Ironruby-core] Problem with using OpenStruct and ERB 
Sent by:        ironruby-core-bounces at rubyforge.org 


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"
However, it generates the following error when I run this in IronRuby on .NET 4.0.30319.269: 
(erb):2: undefined method `foo' for main:Object (NoMethodError) 
Does anyone know how to get this to behave correctly in IronRuby? 
Ironruby-core mailing list
Ironruby-core at rubyforge.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20120619/33d3b76a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 3465 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20120619/33d3b76a/attachment.gif>

More information about the Ironruby-core mailing list