初次学习,重点了解模版,可编辑context,以及最后模板注入
we would create a helper named list to generate our HTML list. The helper receives the people as its first parameter, and an options hash as its second parameter. The options hash contains a property named fn, which you can invoke with a context just as you would invoke a normal Handlebars template.
Handlebars
的 {{expression}}
表达式会返回一个 HTML编码 HTML-escape 过的值。如果不希望Handlebars来编码这些值,使用三个大括号即可:{{{
。
that will invoke a section of your template with a different context than the current. These block helpers are identified by a # preceeding the helper name and require a matching closing mustache, /, of the same name.
嵌套路径 *../*路径链接到父级模板作用域 具体怎么用?context可以有多个??
想起了angular注册指令 循环
{{#each items}}
{{/each}}
注意起始和结束标记
Handlebars.registerHelper('agree_button',function(){
var emotion = Handlebars.escapeExpression(this.emotion);
name = Handlebars.escapeExpression(this.name);
return new Handlebars.SafeString(
"<button>I agree. I " + emotion + " " + name + "</button>"
);
});
Handlebars partials allow for code reuse by creating shared templates. 模板复用 registerPartial里面写好模版