No More Whitespace Worries — Use HAML for Emails!

Tired of all the erb whitespace and those <%-end-%> madness ?

Switch to HAML for emails!!

How to?

  • remove any leading whitespace with capture and gsub
  • use == for easy string replacement
  • use == for newlines


==Hello #{@user},
Your order has been completed on #{}.
You may now access the bought items:
- content = capture do
  - for item in @order.items
    - if item.shipping?
      We will send it to you soon.
    - else
      please download it here:
      ==#{item.orderable} -- #{polymorphic_url(item.orderable)}

=content.gsub(/^(  )*/,'')

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s