In Sendgrid Design template, how to use handlebar iteration for table?

六月ゝ 毕业季﹏ 提交于 2019-12-07 05:19:50

问题


I'm using SendGrid online "Design" template, with a module "code".

In their documentation (https://sendgrid.com/docs/ui/sending-email/editor/#code-modules), they say that de code editor does not modify or validate any HTML.

If I write this piece of code inside the code module:

<ul>
{{#each items}}
    <li>test</li>
{{/each}}
</ul>
<table>
<tbody>
{{#each items}}
    <tr>
        <td>Col 1</td>
        <td>Col 2</td>
    </tr>
{{/each}}
</tbody>
</table>

it results in:

<ul>
{{#each items}}
    <li>test</li>
{{/each}}
</ul>
{{#each items}}{{/each}}
<table>
<tbody><tr>
        <td>Col 1</td>
        <td>Col 2</td>
    </tr></tbody>
</table>

We can see that the {{each}} function stays in the right place for the ul, but is remove from inside of the table. Is this a temporary bug? How can I do this simple operation?

Thanks for your help


回答1:


I found a undocumented way to make this works. You will need to comment out the each helper like this:

<table>
<tbody>
<!-- {{#each items}} -->
    <tr>
        <td>Col 1</td>
        <td>Col 2</td>
    </tr>
<!-- {{/each}} -->
</tbody>
</table>



回答2:


I get the same issue. Definitely a bug in the Design Editor. My work around was to: -> style the email with the Design Editor -> Export html -> go back and create a new version of the transaction email using the 'Code Editor' and not the 'Design Editor' -> paste in the previously exported html -> find the table that needs the {{each}} loop and place the functions exactly as you did



来源:https://stackoverflow.com/questions/53614202/in-sendgrid-design-template-how-to-use-handlebar-iteration-for-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!