How to use if else condition in Meteor Template?

You can use if else condition in Meteor HTML Template by other option
Here is one option to use it

Like: You can use Helpers of meteor to use if else condition which you can use in your HTML file.

Here is Example:
Project/helpers/Spacebars.js

You can write this code in this helper

UI.registerHelper('addChangeClass', function(valchange) {

  if(valchange>1)
  {
    return "<span style='color:green;'>Yes</span>";
  }else
  {
      return valchange;
  }
}); 

Now you can use this function in your template HTML file
<td align="right">{{{addChangeClass -34}}}</td>
or
<td align="right">{{{addChangeClass number}}}</td>

I used {{{ three curly bracket to render HTML in Meteor HTML Template.
  

Comments