MSO条件和ERB标签

时间:2017-05-15 03:54:27

标签: ruby-on-rails ruby email ms-office erb

我试图在rails服务器中的mailer.html.erb中以条件方式嵌入ruby内容。

因为dref似乎无效,因为href呈现&#34; www.example.com/edit/<%= @ user [:id]%&gt; /&lt;%= @user [:reset_digest ]%&gt;&#34;对于mso。

<!--[if mso]>
            <table width="100%" cellpadding="0" cellspacing="0" border="0" style="border-spacing: 0; border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
              <tr>
                <td style="padding-right: 10px; padding-left: 10px; padding-top:10px; padding-bottom:10px;" align="center">
                  <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://www.example.com/doctores/edit/<%= @user[:id] %>/<%= @user[:reset_digest] %>" style="height:42px; v-text-anchor:middle; width:170px;" arcsize="15%" strokecolor="#3AAEE0" fillcolor="#3AAEE0">
                    <w:anchorlock/>
                    <center style="color:#ffffff; font-family:'Helvetica Neue', Helvetica, Arial, sans-serif; font-size:16px;">
<![endif]-->
            <a href="https://www.example.com/doctores/edit/<%= @user[:id] %>/<%= @user[:reset_digest] %>" target="_blank" style="display: inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: #ffffff; background-color: #3AAEE0; border-radius: 6px; -webkit-border-radius: 6px; -moz-border-radius: 6px; max-width: 150px; width: 110px; width: auto; border-top: 0px solid transparent; border-right: 0px solid transparent; border-bottom: 0px solid transparent; border-left: 0px solid transparent; padding-top: 5px; padding-right: 20px; padding-bottom: 5px; padding-left: 20px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;mso-border-alt: none">
              <span style="font-size:12px;line-height:24px;"><span style="font-size: 16px; line-height: 32px;" data-mce-style="font-size: 16px;">Corregir Datos</span></span>
            </a>

由于

1 个答案:

答案 0 :(得分:0)

我找到的唯一解决方案是将你的红宝石变量字符串连接到if块并输出整个mso条件,就像你的情况一样:

<%== '<!--[if mso]>
        <table width="100%" ...>
          <tr>
            <td style="...">
              <v:roundrect ... href="https://www.example.com/doctores/edit/' + @user[:id] + '/' + @user[:reset_digest] + '" style="..." ...>
                <w:anchorlock/>
                <center style="...">
      <![endif]-->' %>

请注意使用&lt;%=='raw'erb标记,我与常规转义的&lt;%=标记有不一致的结果。

坦率地说,这是一个丑陋的hacky解决方案,但它不像使用电子邮件的mso标签那样漂亮;)