Spacebar/Meteor : Nested {{#if}} and Global template helpers

别来无恙 提交于 2019-12-25 03:51:12

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/32806020/spacebar-meteor-nested-if-and-global-template-helpers

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