Template node - displaying a value rounded to 1dp

I have this in a template node

<div class="subtitle">{{msg.payload.hourly[1].temp}}</div>

But the data has 2 decimal places, I want to round it to 0 or 1.
Is it possible to do this within the {{ }} (Moustache template?)
I am sure I've seen something like {{msg.payload.hourly[1].temp | 1}}, but that causes all my mustaches to be displayed as literals
Untitled 10

The whole squiggly bracket issue is very confusing. I have seen snipppets in various contexts with { }, {{ }}, and even {{{ }}}. Even the spelling is problematic. :face_with_raised_eyebrow:

In a ui_template (and possibly other ui nodes) you can use Angular's number filters

<div class="subtitle">{{msg.payload.hourly[1].temp | number:0}}</div>

Outstanding, thank you Andy.
Untitled 1

Is the | number:1 bit interpreted by a different library from the {{ }} ? How do they know which does what?

I believe both the {{ }} and the filter | number:1 are intepreted by the AngularJS library, that the Dashboard is based on. Dont know much about its inner workings .. but you can check what else is available on AngularJS Filters

ps. nice weather presentation :+1:

Thanks.

Next, all those icons need the time under them, and since the weather is in Rio and I'm in England I have to calculate and add in timezone difference. I don't think I'll attempt that in the template code!

Ohh nice! I hope you decide to share this.

Working demo.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.