Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating custom Handlebars helper with Mandrill?

Is there a way to define a custom Handlebars helper with Mandrill? Say that I've got an object and the currency is in cents.

  "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"
    },
  ]

I've got this template:

            <!-- 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}}

I want to take price, which is in cents, and write a custom helper toCurrency that simply divides it by 100.

Custom helpers are easy enough to do in standard Handlebars, but is it possible with Mandrill's utilization of it?

like image 367
fuzzybabybunny Avatar asked Nov 08 '22 19:11

fuzzybabybunny


1 Answers

According to the documentation this isn't possible :

"Use Handlebars regardless of whether you're using templates in Mandrill. We'll cover the basics of Handlebars, helpers implemented specifically for Mandrill, and some deviations from and additions to standard Handlebars."

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

There are not even all helpers from handlebar.

like image 98
Christophe Avatar answered Dec 06 '22 10:12

Christophe