使用Mandrill创建自定义Handlebars助手?

fuz*_*nny 5 handlebars.js mandrill

有没有办法用Mandrill定义自定义Handlebars助手?假设我有一个对象而且货币是美分.

  "products": [
    {
      "sku": "hdrPhotos",
      "price": 19000,
      "title": "Unlimited HDR Photography"
    },
    {
      "sku": "panos",
      "price": 2500,
      "title": "Panoramas / Virtuals"
    },
    {
      "sku": "fullVideo",
      "price": 43000,
      "title": "Full Video"
    },
    {
      "sku": "aerialDaytimePhotos",
      "price": 17500,
      "title": "Aerial Daytime Photography"
    },
  ]
Run Code Online (Sandbox Code Playgroud)

我有这个模板:

            <!-- BEGIN PRODUCT LOOP // -->
            {{#each products}}
            <tr class="item">
              <td valign="top" class="textContent">
                <h4 class="itemName">{{title}}</h4>
                <span class="contentSecondary">${{toCurrency price}}</span>
                <br/>
                <span class="contentSecondary sku"><em>{{sku}}</em></span>
                <br/>
              </td>
            </tr>
            {{/each}}
Run Code Online (Sandbox Code Playgroud)

我想采取price,以美分为单位,并编写一个自定义帮助器toCurrency,简单地将它除以100.

定制助手在标准把手中很容易做到,但是Mandrill能否利用它?

Chr*_*phe 1

根据文档,这是不可能的:

“无论您是否在 Mandrill 中使用模板,都可以使用 Handlebars。我们将介绍 Handlebars 的基础知识、专门为 Mandrill 实现的帮助程序,以及标准 Handlebars 的一些偏差和补充。”

参考:https://mandrill.zendesk.com/hc/en-us/articles/205582537-Using-Handlebars-for-Dynamic-Content#using-helpers

甚至没有所有来自车把的帮手。