Markdown #eq not comparing strings

I have an issue with Markdown inside a GPS history block.
I’m trying to display specific attributes based on a devices tag (.Template, in this case), but the code below does not work, and i can not figure out why…

##### [{{deviceName}}](https://XXX.onlosant.com/?device={{deviceId}})
{{#if isLastPoint}} 
#######(Current Location){{else if isFirstPoint}} (Starting Location)
{{/if}}
{{#eq deviceTags.Template "Weather Station"}}
##### Rain Fall: {{data.Rainfall}} mm
##### WindspeedAVG: {{data.WindSpeedAverage}} m/s
{{/eq}}
{{#eq deviceTags.Template "Tank Level"}}
##### Level: {{data.Level}} m 
{{/eq}}
###### Dev Temp :  {{deviceTags.Template}}

The last ###### Dev Temp : {{deviceTags.Template}} works perfectly, and returns the exact text I am comparing to using {{#eq}}.

Any help will be appreciated!

Hello Picalz and welcome to the Losant Forums!

What you’re seeing here is a bit of a quirk with Handlebars.

deviceTags.Template is actually an array. If you render an array ({{deviceTags.Template}} ), it renders them as comma-separated values. When the array has one item in it as it does in this case, that gives the same result as {{deviceTags.Template.[0]}}.

However, our {{#eq}} block helper does not behave the same way when handed an array as one of the values to compare.

So what’s actually happening here is you’re comparing the array {{deviceTags.Template}} to the string “Weather Station”.

What you should try do instead is compare the first item in the array to that string - {{#eq deviceTags.Template.[0] 'Weather Station'}}.

Let us know how it goes!

Hi Sabastian,

Thank you very much!
This solves it 100%. Ill have to keep this behavior in mind going further :slightly_smiling_face: .