How to template with a loop

Hello Losant Team.

I have a Loop and inside it i have a Math Node with this:
{{data.itemLoop.value.valueToSum}} - {{data.listETr.[(data.itemLoop.index)].value}}
listETr is an array that contain the same length that the array that i provided to the loop node and i triyng to do some like this “listETr[i].value”. Is this possible in Losant?

Thanks :slight_smile:

There is indeed: the {{lookup}} helper. This is actually a native Handlebars helper that is supported within Losant.

So, if you’re iterating over the array data.itemLoop and want to pull a value from data.listETr dependent on which iteration you’re on, you can reference that value like so:

{{lookup data.listETr data.itemLoop.index}}

If that item resolves to an object - as in, you can nest multiple {{lookup}} helpers to get what you’re after …

{{lookup (lookup data.listETr data.itemLoop.index) 'value'}}