You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
This 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
# Default implementation used.
class_attribute :erb_implementation
self.erb_implementation = Erubis # 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
).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.
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 <% %>.
So,
How to get rid of blank spaces without switching to Slim, Haml, etc?
Why Rail say See the ERB documentation for more information if default Erubis doesn't support ERB trim modes like <>%?
I use:
Rails 3.2.13
ruby 1.9.3p392 (2013-02-22) [i386-mingw32]
under Windows XP
The text was updated successfully, but these errors were encountered:
Rails responses with a page full of blank spaces:
The text from Rails guide:
This is a code from
gems\actionpack-3.2.13\lib\action_view\template\handlers\erb.rb
:From official Erubis docs:
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.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
<% %>
.So,
See the ERB documentation for more information
if default Erubis doesn't support ERB trim modes like<>%
?I use:
Rails 3.2.13
ruby 1.9.3p392 (2013-02-22) [i386-mingw32]
under Windows XP
The text was updated successfully, but these errors were encountered: