Can write custom helpers handlebars in indicator block?

Hello Losant Team!

I have this in an indicator

And i need that when the differences get a negative number return 0. I know that handlebarjs has custom Helpers but i don’t know if there is a way to resolve with this or another solution, maybe with a IF?. Thanks :slight_smile:

Here’s a snippet that demonstrates what you’re looking for. This one uses the #with helper to pre-calculate the math and store it as a variable that can be used multiple times.

{{#with (subtract value-2 value-3) as |result|}}

{{#lt result 0}}
The result is **less** than zero: {{result}}
The result is **greater** than zero: {{result}}


You can experiment with the above template here.

We do have a really good Deeper Dive webinar on Advanced Templating that I’d also recommend checking out.

1 Like

Works perfectly Brandon. Thank you very much