0
In need to check this scenario using handle bar templates
if(data.Id==1 && Isreal==false)
{
//`enter code here
}
else if(data.id==2 && IsReal==true)
//other html
else
`//enter code here`last html

How can I do that, I tried using helper but it is not working in my case

Deepika Thakur
  • 173
  • 3
  • 11

1 Answers1

0

Best practice is to not do any business logic in the template but instead do it before and pass it through the context into the template.

i.e.

var context = {
    dataOneNotReal = data.Id==1 && Isreal==false,
    dataTwoIsReal = data.id==2 && IsReal==true
};

then in the template

{{#if dataOneNotReal}}
    // code
{{else}}
    {{#if dataTwoIsReal}}
        // code
    {{else}}
        // code
    {{/if}}
{{/if}}
vanmeter-t
  • 63
  • 8