2

I want to check two more condition in IF Helper in Handlebars.

Can some one help me with it.

i want something like the below one :

 status = "success";
 {{ifCond status '==' 'success' && status '==' 'pass'}}
Christophe
  • 2,131
  • 2
  • 21
  • 35
Karthik Sekar
  • 665
  • 1
  • 5
  • 10

1 Answers1

0

To my mind you have a problem because status can't be at the same time pass and success...

Use 2 variable instead status and check for example :

{ "status" : "success" , "check" : "pass" }

You can have more than just one parameter in a helper :

Handlebars.registerHelper('ifCond', function( cond1, cond2) {
   if (cond1 == 'success' && cond2 == 'pass') {
      return "OK";
   } else {
      return "KO";
   }
});

the code in your template will look like that :

{{ifCond status check}}
Christophe
  • 2,131
  • 2
  • 21
  • 35