meteorspacebars

spacebars: how to use and / or in if statements


I have following code:

 <div class="form-group {{#if afFieldIsInvalid name='latitude' OR name='longitude'}}has-error{{/if}}">......</div>

How can I use AND/OR in if conditions of spacebars templates ?


Solution

  • Spacebars is an extension of Handlebars, which is designed to be a logic-less template language.

    The solution is to register a helper. For the general case, see these similar questions:

    To define helpers in Meteor, use Template.registerHelper