0
我試圖在Mandrill中創建一個Handlebars模板,它將打印出一列項目。我們使用的{{#each}}
結構來做到這一點:Mandrill上的{{#each ...}}產生一個空字符串
{{#each bottles}}
<p>{{this.bottle_title}}</p>
<p>{{this.description}}</p>
<p>{{this.price}}</p>
{{/each}}
而且,我們正在傳遞JSON這樣的:
{/*...*/
'bottles' : [
{
"wine_id":"1599",
"bottle_title":"2012 Sapphire Hill \u2018Ketchum Reserve\u2019 Pinot Noir",
"description":"<p>\n <strong>Winemaker Notes:<\/strong><br \/>\n Blended from 4 clones, with 115 and 777 dominating to create this bold yet balanced wine. Aged for 20 months on French oak, this wine flaunts bright cherry, blackberry, and subtle vanilla with a very long finish.<br \/>\n <\/p>\n",
"price":"50"
},
{
"wine_id":"1600",
"bottle_title":"2012 Sapphire Hill \u2018D\u2019Argento\u2019 Pinot Noir",
"description":"<p>\n <strong>Winemaker Notes:<\/strong><br \/>\n D'Argento (Silver) was crafted for our 25th Anniversary and uses 4 clones from the fabled Ketcham Estate in Russian River Valley....<\/p>\n",
"price":"52"
}
] /*...*/
}
我驗證過,如果我只是打印出來{{bottles}}
然後我得到完整的JSON輸出到電子郵件中。但是{{#each bottles}}{{this.bottles}}{{/each}}
沒有打印出任何東西,我們上面的例子也沒有。任何想法,我們如何才能得到這個工作?
非常感謝您的幫助!