Whatever I do I get a response page rendered like this:
Every page is rendered with blank spaces. Even if I put HTML and ERB tags together inline:
## Not together inline, blank spaces are like on the picture above:
<%= @foo %>
## Together inline, see the result lower:
*## Result from t**ogether inline. *Blank spaces exists either but now look like this:
“” ## see the difference? Two double quotes together, not with a space in-between. But anyway it is rendered!
What I’ve learned so far:
The text from Rails guide:
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.
But at the same time they say that the Erubis is the default template engine in Rails, not ERB:
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.
And here is a code from gems\actionpack-3.2.13\lib\action_view\template\handlers\erb.rb:
# 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`
From official Erubis docs:
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().
So it is obvious that
: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.
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?