From: RichardOnRails Date: 2011-03-01T08:05:25+09:00 Subject: Re: erb example from comp.lang.ruby fails On Feb 28, 2:20 pm, Phillip Gawlowski wrote: > On Mon, Feb 28, 2011 at 8:00 PM, RichardOnRails > > > > wrote: > > I copied code fromhttp://www.ruby-doc.org/stdlib-1.8.6/(erb package > > in Table of Contents, ERB in Classes column. > > > I edited it only slightly in SciTE and pasted it inhttp://www.pastie.org/1617782 > > > Running the code from within SciTE 1.74 gave me the error message: > > (erb):16: undefined local variable or method `priority' for > > main:Object (NameError) > >        from K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/1.8/erb.rb:741:in > > `value' > >        from K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/1.8/erb.rb:741:in > > `result' > >        from erb1.rb:43 > > > I'm running ruby 1.8.6 under WinXP-Pro/SP3 > > > If there's a easily recognized fix,  I'd like to apply it to this > > example.  Meanwhile,  I'll try other examples that might both work and > > suggest a hint at why this example fails. > > This seems to be the offending code: > <%# ignore numerous minor requests -- focus on priorities %> >     % priorities.each do |priority| >       * <%= priority %> >     % end > > Try this instead: > > <%# ignore numerous minor requests -- focus on priorities %> >     <% priorities.each do |priority| > >       * <%= priority %> >     < % end > > > -- > Phillip Gawlowski > > Though the folk I have met, > (Ah, how soon!) they forget > When I've moved on to some other place, > There may be one or two, > When I've played and passed through, > Who'll remember my song or my face. Hi Phillip, Thanks for you response, which essentially solved my problem. I published a new version, with a copy of printed output appended, at http://www.pastie.org/1617782 > Try this instead: > > <%# ignore numerous minor requests -- focus on priorities %> > <% priorities.each do |priority| > > * <%= priority %> > < % end > After following your suggestion and getting different failure, I finally realized: Hey, that's just regular ERB code. Therefore, that "*" out there would lead to: string * string * string which violates Ruby syntax. So I got rid of the "*" and got decent (but not perfect results): Too many blank lines are generated. I eliminated one of the blanks by appending a closing hyphen at line 24. But I couldn't plug the major generated, I believe, by line 26. Cf. output lines 70-72, 74,76,78 in the Pastie. If you have have any insight into that problem, I'd appreciate one more insight from you. Best wishes, Richard