空格键/流星:嵌套{{#if}}和全局模板帮助器

亚历山大·伯利尔(Alexandre Bourlier)

我愿意根据Session变量设置应用程序的标题

这是空格键模板

{{#if session 'header'}}
  <header id="page_header">
    {{#if session 'header_left'}}
      <a class="left_btn" href="{{session 'header_left'}}">{{session 'header_left'}}<a>
    {{/if}}

    <h1>{{session 'header'}}</h1>

    {{#if session 'header_right'}}
      <a class="right_btn" href="{{session 'header_right'}}">{{session 'header_right'}}<a>
    {{/if}}
  </header>
{{/if}}

这是我定义全局“会话”助手的方式

Template.registerHelper('session', function(input){
  return Session.get(input);
});

这是我遇到的错误

 Errors prevented startup:

 While building the application:
 client/main.html:17: Unexpected closing template tag
 ...}}<a>         {{/if}}          <h1>{{sess...
 ^

我看不到合奏有什么问题。{{#if}}流星中标签嵌套有问题吗?

任何建议都是最欢迎的。

基思·尼古拉斯(Keith Nicholas)

也许是因为您需要a</a>来完成锚点?

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章