Native ERB in ruby, and eruby, seem to lack the -%> feature for suppressing trailing newlines. Thus erb -n script gives errors. Where is Rails ERB so I can invoke it directly? Thank you Hugh
It''s a standard library located in /usr/local/lib/ruby/1.8/erb.rb In order to enable a trim mode -%> you have to instantiate ERB object with trim mode parameter like e = ERB.new(str, nil, ''-'') -- Kent --- http://www.datanoise.com On 2/20/06, Hugh Sasse <hgs@dmu.ac.uk> wrote:> Native ERB in ruby, and eruby, seem to lack the -%> feature for > suppressing trailing newlines. Thus > erb -n script > gives errors. Where is Rails ERB so I can invoke it directly? > Thank you > Hugh > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Mon, 20 Feb 2006, Kent Sibilev wrote:> It''s a standard library located in /usr/local/lib/ruby/1.8/erb.rb > > In order to enable a trim mode -%> you have to instantiate ERB object > with trim mode parameter like > > e = ERB.new(str, nil, ''-'')Ah, so I need erb -T - file -T [trim_mode] specify trim_mode (0..2, -) Thank you. I couldn''t find that before, but trim mode was the key.> > -- > KentHugh
> In order to enable a trim mode -%> you have to instantiate ERB object > with trim mode parameter like > > e = ERB.new(str, nil, ''-'') >Inside rails, I add the following line in my config/custom_environment.rb ActionView::Base.erb_trim_mode=''%<>-'' that enables all erb options % enables Ruby code processing for lines beginning with % <> omit newline for lines starting with <% and ending in %> > omit newline for lines ending in %> Simo AddSW -- Posted via http://www.ruby-forum.com/.
On Mon, 20 Feb 2006, Simo Gal wrote:> Inside rails, I add the following line in my > config/custom_environment.rb > > ActionView::Base.erb_trim_mode=''%<>-'' > > that enables all erb options > > % enables Ruby code processing for lines beginning with % > <> omit newline for lines starting with <% and ending in %> > > omit newline for lines ending in %>by which I think you meant: - omit newline for lines ending in -%> Thank you. My problem was how to reproduce it outside rails, but this is good to know too.> > Simo > AddSW >Hugh
Michael Trier
2006-Feb-20 17:26 UTC
[Rails] Re: Native erb lacks -%>, where is Rails'' erb?
I really like the % option, but it doesn''t seem to be something that''s embraced in the community. Why is that? Michael
Kent Sibilev
2006-Feb-20 18:15 UTC
[Rails] Re: Native erb lacks -%>, where is Rails'' erb?
Maybe that because there is a recommendation to use helpers for cases that require an even slightly more complicated logic in views. On 2/20/06, Michael Trier <mtrier@gmail.com> wrote:> I really like the % option, but it doesn''t seem to be something that''s > embraced in the community. Why is that? > > Michael > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Kent --- http://www.datanoise.com