使用handlebars模板和TinyMCE

5

我正在尝试使用TinyMCE来让我的用户修改一个handlebars报告模板。该模板包含一些不适用于TinyMCE的元素,它们正在被移动。请参见{{#each data}}和{{/each}}

以下是我的handlebars模板的良好HTML代码:

<table class="table table-bordered">
     <thead>
          <tr>
               <th><h4>Item</h4></th>
               <th><h4 class="text-right">Quantity</h4></th>
               <th><h4 class="text-right">Rate/Price</h4></th>
               <th><h4 class="text-right">Sub Total</h4></th>
          </tr>
    </thead>
    <tbody>
        {{#each Details}}
           <tr>
                <td>{{Item}}<br><small>{{Description}}</small></td>
                <td class="text-right">{{Quantity}}</td>
                <td class="text-right">{{Rate}} {{UnitOfMeasure}}</td>
                <td class="text-right">{{Amount}}</td>
          </tr>
        {{/each}}  
     </tbody>
</table>

在我将代码粘贴到TinyMCE中后,结果如下:
{{#each Details}}{{/each}}
<table class="table table-bordered">
<thead>
<tr><th>
<h4>Item</h4>
</th><th>
<h4 class="text-right">Quantity</h4>
</th><th>
<h4 class="text-right">Rate/Price</h4>
</th><th>
<h4 class="text-right">Sub Total</h4>
</th></tr>
</thead>
<tbody>
<tr>
<td>{{Item}}<br /><small>{{Description}}</small></td>
<td class="text-right">{{Quantity}}</td>
<td class="text-right">{{Rate}} {{UnitOfMeasure}}</td>
<td class="text-right">{{Amount}}</td>
</tr>
</tbody>
</table>

有人遇到过可以帮助我的插件或其他什么东西吗?


你找到任何解决方案了吗? - Derese Getachew
2个回答

3

我刚遇到了这个问题...我有一个订单确认电子邮件,需要在一个表格中配置订单项目列表;同样的问题。

我刚才意识到,我可能不应该使用表格,因为它们不是响应式的,但我最终通过HTML注释解决了问题,就像这样:

<tr style="font-weight: bold;">
  <td style="width: 145px;">Qty</td>
  <td>Item</td>
  <td>Unit Price</td>
  <td>Total</td>
</tr>
<!--{{#order.line_items}} -->
<tr repeat="">
  <td style="width: 145px;">{{quantity}}</td>
  <td>{{product.name}}</td>
  <td>{{currency unit_price}}</td>
  <td>{{currency total}}</td>
</tr>
<!--{{/order.line_items}} -->
<tr>
  <td style="width: 145px;">&nbsp;</td>
  <td>&nbsp;</td>
  <td><strong>Subtotal:</strong></td>
  <td>{{currency order.subtotal}}</td>
</tr>

表格在电子邮件中是完全可以使用的,因为电子邮件客户端无法生成响应式CSS。 - CodeShaman

1
我能够在我的 <Element> 上使用自定义属性,并使用:
<tr repeat="{{#each Details}}">
</tr repeat="{{/each}}">

3
哇,我已经花了10个小时在寻找解决方案上,解决的问题与这个完全一样。请提供更详细的答案,不胜感激。 - gisderdube

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接