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
on 2006-02-20 13:25
on 2006-02-20 15:05
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 2006-02-20 15:50
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. > > -- > Kent Hugh
on 2006-02-20 17:00
> 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
on 2006-02-20 17:13
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
on 2006-02-20 18:30
I really like the % option, but it doesn't seem to be something that's embraced in the community. Why is that? Michael
on 2006-02-20 19:16
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
on 2006-02-20 19:28
Perhaps, but I'm not really advocating doing anything more than: % for list in @lists <tr>list.name</tr> % end To me that's six characters with shift keys that I don't have to type. :) Michael
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.