【发布时间】:2016-08-21 09:53:10
【问题描述】:
我正在将电子邮件模板从 Mandrill 移动到 Postmark,这需要将 Handlebars 转换为 Mustachio。在 Handlebars 中,我有这样的东西:
{{#if some_variable}}
<p>This text uses variable: {{some_variable}}
{{/if}}
根据 Mustache 文档,转换后应该如下所示:
{{#some_variable}}
<p>This text uses variable: {{some_variable}}
{{/some_variable}}
问题在于 Postmark 的 Mustachio 使用范围界定 (https://github.com/wildbit/mustachio/wiki#scoping),因此在这种情况下,它需要以下 JSON 模型:
{
"some_variable": {
"some_variable": "some_variable_value"
}
}
而不是
{
"some_variable": "some_variable_value"
}
有谁知道如何关闭 Mustachio 的范围,因此它使用预期的示例 JSON 模型?到目前为止,我看到的唯一解决方法(肮脏的一种)是以这种嵌套对象形式传递模板模型,但我已经发现它不适用于所有情况。提前感谢,任何帮助表示赞赏。
【问题讨论】: