From: RichardOnRails Date: 2011-03-01T09:05:30+09:00 Subject: Re: erb example from comp.lang.ruby fails On Feb 28, 2:38 pm, Sean O'Halpin wrote: > On Mon, Feb 28, 2011 at 7: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. > > > Thanks in Advance, > > Richard > > That ".gsub(/^  /, '')" at the end of the template is the clue. It > deletes the first two spaces at the beginning of each line. > The '%' modifier works only at the very beginning of each line. If you > change either the indent of the template to two spaces > or change the gsub to replace the same number of spaces you've > indented by, the example will work. > > Regards, > Sean Hi Sean (namesake of my 6-yo grandson), Great job. I posted the corrected version, including appended output, at http://www.pastie.org/1618793. I recognized how the gsub would affect the earlier code, but saw no purpose for it ... because I never heard about a % sign in the first column producing some special effect. Do you know where that's documented online? The Pastie proves that the code produces excellent output. Many thanks, Richard