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
On Mon, 20 Feb 2006, Kent S. 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 likee = 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
In order to enable a trim mode -%> you have to instantiate ERB object
with trim mode parameter likee = 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
I really like the % option, but it doesn’t seem to be something that’s
embraced in the community. Why is that?
Michael
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 T. [email protected] 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
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Kent
On Mon, 20 Feb 2006, Simo Gal wrote:
Inside rails, I add the following line in my
config/custom_environment.rbActionView::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
Perhaps, but I’m not really advocating doing anything more than:
% for list in @lists
To me that’s six characters with shift keys that I don’t have to type.
Michael