我可以在jQuery模板中声明local / temp变量吗?

问题描述:

是否可以在jQuery模板语法中声明新变量?我希望达到相当于这个(这不起作用):

Is it possible to declare new variables within the jQuery template syntax? I'm hoping to achieve the equivalent of this (which does not work):

{{var test = "test"}}

<div>
    ${test}
</div>


这是非常蹩脚的,但可能有效的一招是:

This is pretty lame, but one trick that might work is:

  {{each(i, test) ["test"]}}
    blah blah ${test} blah
  {{/each}}

我不是百分百肯定然而是关于使用像这样的数组常量表达式;我会设置一个小提琴。 (编辑是的有效: - )

I'm not 100% sure however about using an array constant expression like that; I'll set up a fiddle. (edit yes it works :-)