From: Sean O'Halpin Date: 2011-03-01T04:38:57+09:00 Subject: Re: erb example from comp.lang.ruby fails On Mon, Feb 28, 2011 at 7:00 PM, RichardOnRails wrote: > I copied code from http://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 in http://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