Prakarangs
Prakarangs

Reputation: 49

How to leave tag open in HAML?

I am working on responsive html email without media query and need to insert some mso condition. However, I am not sure how can I convert this into HAML?

<!--[if (gte mso 9)|(IE)]>
<table class="outlook-wrapper">
    <tr>
          <td>
<![endif]-->
<table class="email-body">
// Some email content ..
</table>
<!--[if (gte mso 9)|(IE)]>
       </td>
    </tr>
</table>
<![endif]-->

How do i force haml to leave the tag open for my outlook wrapper? So I can close it myself after email-body table.

Upvotes: 0

Views: 265

Answers (1)

froderik
froderik

Reputation: 4808

Hmm. Tricky thing. I guess you could do something like:

<!--[if (gte mso 9)|(IE)]>
%table.outlook-wrapper
  %tr
    %td
      %table.email-body
        -# some email content
<![else]-->
%table.email-body
  -# some email content
<![endif]-->

But I am sure you don't like the redundancy. To avoid that I would put the inner table in a partial:

<!--[if (gte mso 9)|(IE)]>
%table.outlook-wrapper
  %tr
    %td
      = render :email_body
<![else]-->
= render :email_body
<![endif]-->

(The render call would depend on what you are using around haml. Something like the above would probably work with rails.)

Upvotes: 0

Related Questions