<%= @foo %>
"" ## see the difference? Two double quotes together, not with a space in-between. But anyway it is rendered!
config.action_view.erb_trim_mode gives the trim mode to be used by ERB. It defaults to '-'. See the ERB documentation for more information.
NOTICE: Rails 3 adopts Erubis as default default engine. You don't need to do anything at all when using Rails 3. This section is for Rails 2.
# Specify trim mode for the ERB compiler. Defaults to '-'. # See ERB documentation for suitable values. class_attribute :erb_trim_mode self.erb_trim_mode = '-' ### yes, trim mode is set by dafault. But it is nothing for Erubis. # Default implementation used. class_attribute :erb_implementation self.erb_implementation = Erubis ### yes, Erubis is instead of ERB self.class.erb_implementation.new( erb, :escape => (self.class.escape_whitelist.include? template.mime_type), :trim => (self.class.erb_trim_mode == "-") ### so :trim is true, just because self.erb_trim_mode = '-'. That's all.
).src`
Erubis deletes spaces around '<% %>' automatically, while it leaves spaces around '<%= %>'.
If you want leave spaces around '<% %>', add command-line property '--trim=false'.
Or add option :trim=>false to Erubis::Eruby.new().
:trim => (self.class.erb_trim_mode == "-") will never remove spaces around <%= %>. Because there is no option in Erubis for it. And this is exactly seen on the picture above.This line self.erb_implementation = Erubis informs that Rails implements Erubis instead of ERB.
But as written above the only trim mode Erubis supports is around <% %> , just pass true or false only.
So any experiments with true ERB options (< % > -) yields nothing. Because Erubis just doesn't support them.
My question: How to get rid of those blank spaces without switching to Slim, Haml, etc?
Why Rails say in their guide See the ERB documentation for more information if it means nothing for default Erubis?