Whatever I do I get a response page rendered like this:

<https://lh3.googleusercontent.com/-G9KpqL6QGKE/UZ9afeLuFpI/AAAAAAAAABk/r5rITlX-kzc/s1600/rails_render.png>
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:*
*<div>*

*<%= @foo %>*

*</div>*


*## Together inline, see the result lower:*
*<div><%= @foo %></div>*


*## Result from t**ogether inline. **Blank spaces exists either but now 
look like this:*
*<div class="foo">*

*""*  *## see the difference? Two double quotes together, not with a 
space in-between. But anyway it is rendered!*

*</div> *

What I've learned so far:

The text from Rails 
guide<http://edgeguides.rubyonrails.org/configuring.html#configuring-action-view>
:

*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<http://www.kuwata-lab.com/erubis/users-guide.05.html>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.

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<http://ruby-doc.org/stdlib-2.0/libdoc/erb/rdoc/ERB.html#method-c-new>(
*< % > -)* 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?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/a7adf722-821a-460c-9a30-f4576e97e1d3%40googlegroups.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to