如何在 "ifequal" 车把中包含变量?

How do I include a variable in an "ifequal" handlebar?

我正在使用 Foundation for Sites,它使用 Panini and Handlebars 进行 JS 模板化。我需要一个包含 js 变量的 {{#ifequal}} 语句,以便我可以将 URL 参数与 JSON

进行比较

我现在拥有的:

{{#ifequal "Canada" this.destination}} //do the thing {{/ifequal}}

我需要的是这样的:

{{#ifequal <script>document.write(destId)</script> this.destination}} //do the thing {{/ifequal}}

js var "destId" 是在从 URL 参数中拉出时在页面的前面分配的,但是我当然不能将脚本包含在把手中。如果有一种方法可以将 URL 参数直接传递到把手中,那也可以。

如前所述(link is here):

Handlebars partials take a second parameter which becomes the context for the partial:

{{> person this}}

In versions v2.0.0 alpha and later, you can also pass a hash of named parameters:

{{> person headline='Headline'}}

You can see the tests for these scenarios: https://github.com/wycats/handlebars.js/blob/ce74c36118ffed1779889d97e6a2a1028ae61510/spec/qunit_spec.js#L456-L462 https://github.com/wycats/handlebars.js/blob/e290ec24f131f89ddf2c6aeb707a4884d41c3c6d/spec/partials.js#L26-L32