2015-02-24 25 views
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 &nbsp;<\/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&#39;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}}没有打印出任何东西,我们上面的例子也没有。任何想法,我们如何才能得到这个工作?

非常感谢您的帮助!

回答

2

当我们认为当我们做了{{bottles}}之后,我们认为正常的JSON写入了电子邮件,我们意识到我们对JSON进行了双重编码。卫生署!所以对于遇到这个问题的其他人,请确保你没有犯同样的愚蠢错误:)

相关问题