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

1

0

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.

Kellykellyann answered 27/9, 2015 at 8:31 Comment(0)
W
1

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

Wolver answered 27/9, 2015 at 8:37 Comment(1)
Life is simple, isn't itKellykellyann

© 2022 - 2024 — McMap. All rights reserved.