Handlebars templates using ampersand and caret

主宰稳场 提交于 2019-12-07 00:55:34

问题


We found some old Handlebars templates which are working fine, but include some odd usage of Handlebars.

The two strange ones are

{{^is_question}}{{/is_question}}

and

{{& answer}}

Neither of those are listed in the Handlerbars docs and there are no helpers defined.

Anyone know what they do?

The ^is_question appears to be used interchangeably with {{#if is_question}}. Maybe it is some deprecated shorthand notation?

The template is compiled the same way we compile other templates:

template = Handlebars.compile(ItemTemplate)

Our handlebars version is:

Handlebars.VERSION = "1.0.0-rc.3";

回答1:


I've used ^ relatively recently, but I had to look up &:

{{^ question}} X {{/question}} => inverse selection, i.e. if (! question ) X;
{{& answer}} => unescaped, typically: {{{answer}}}


来源:https://stackoverflow.com/questions/27026519/handlebars-templates-using-ampersand-and-caret

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!