views:

14

answers:

1

When i indent code in a mailer-view, i see the indentation in the sent (plain text-)mail, too. Is there a way to avoid this without writing my code without indentation…?

A: 

I have faced the same issue previously, but at that time I chose not to indent the code.

Perhaps you could make a helper method that removes indentation (assuming that you do not want indentation at all in your mail). Something like:

<% no_indentation do %>
  Here goes my content.
  <% if @show_extra %>
    And this is some extra indented text
  <% end %>
<% end %>

And then in a helper:

#some_helper.rb
module MyHelper
  def no_indentation(&block)
    #Capture the content of the block,
    #and replace multiple spaces/tabs with a single space.
  end
end

I have not tried this out myself, but it could be worth a try.

Daniel Abrahamsson
Thanks, that works. Anyway i decided to use HTML as content type to have a better control of the display.
Arne Cordes