空格键/流星:嵌套{{#if}}和全局模板助手 [英] Spacebar/Meteor : Nested {{#if}} and Global template helpers

查看:355
本文介绍了空格键/流星:嵌套{{#if}}和全局模板助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



以下是 Spacebars模板

  {{#if session'header'}} 
< header id =page_header>
{{#if session'header_left'}}
< a class =left_btnhref ={{session'header_left'}}> {{session'header_left'}}<一个>
{{if}}

< h1> {{session'header'}}< / h1>
$ b $ {{#if session'header_right'}}
{{/ if}}
< / header>
{{/ if}}

以下是我如何定义会话助手

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

以下是我遇到的错误

 错误导致启动失败:

构建应用程序时:
client / main.html:17:意外关闭模板标记
...}}< a> {{/ if}}< h1> {{sess ...
^

虽然我看不出合成器有什么问题。
流星中嵌套 {{#if}} 标签有问题吗?



任何建议都是值得欢迎的。 可能是因为您需要< / a> 来完成您的定位?


I am willing to set the header of my app, based on Session variables.

Here is the Spacebars template :

{{#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}}

Here is how I defined the global "session" helper :

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

Here is the error I am having :

 Errors prevented startup:

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

I can't see anything wrong with the synthax though. Something wrong with the nesting of {{#if}} tags in Meteor?

Any suggestion is most welcome.

解决方案

maybe because you need a </a> to finish your anchor?

这篇关于空格键/流星:嵌套{{#if}}和全局模板助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆