问题
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