Mandrill 上的 {{#each ... }} 导致空字符串
{{#each ... }} on Mandrill is resulting in an empty string
我正在尝试在 Mandrill 中创建一个 Handlebars 模板,它将打印出项目列表。我们正在使用 {{#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}}
没有打印出任何东西,我们上面尝试的例子也没有。有什么想法可以使它正常工作吗?
非常感谢您的帮助!
当我们考虑 {{bottles}}
时常规 JSON 被写入电子邮件时,我们意识到我们正在对 JSON 进行双重编码。呸!因此,对于遇到此问题的任何其他人,请确保您没有犯同样的愚蠢错误:)
我正在尝试在 Mandrill 中创建一个 Handlebars 模板,它将打印出项目列表。我们正在使用 {{#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}}
没有打印出任何东西,我们上面尝试的例子也没有。有什么想法可以使它正常工作吗?
非常感谢您的帮助!
当我们考虑 {{bottles}}
时常规 JSON 被写入电子邮件时,我们意识到我们正在对 JSON 进行双重编码。呸!因此,对于遇到此问题的任何其他人,请确保您没有犯同样的愚蠢错误:)