Reputation: 3344
Trying to compare two template variables is resulting in an error. This seems consistent with jade syntax. What's wrong here?
Code:
if name == current_project.name
| Current
else
a.nav-project-selection Set as Current
Error:
While building the application:
client/templates/account.jade: Jade syntax error: Expected identifier, number, string, boolean, or null
{{#if name == current_project.na...
^
Upvotes: 2
Views: 463
Reputation: 7996
An easier way is to use the Meteor-handlebar-helpers package.
meteor add raix:handlebar-helpers
Check the readme file to get an overview of the helpers. In your case:
if $eq name current_project.name
| Current
Upvotes: 0
Reputation: 3344
SOLVED
Since Jade compiles down to Spacebars which doesn't support comparison, you have to do it via a helper function. The following worked for me:
client.js
UI.registerHelper('equals', function(a, b) {
return (a === b);
});
template
if equals name current_project.name
| Current
else
a.nav-project-selection Set as Current
Upvotes: 3