# Template node - displaying a value rounded to 1dp

**URL:** <https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608>\
**Category:** Dashboard\
**Created:** [1 February 2022 22:20 UTC](https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608 "2022-02-01T22:20:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 February 2022 22:20 UTC](https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608/1 "2022-02-01T22:20:04Z")

</div>

I have this in a template node

```auto
<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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/6/06c68c5912eaedb5797821399c0be897b31fbc2f.jpeg)

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

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [1 February 2022 22:31 UTC](https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608/2 "2022-02-01T22:31:01Z")

</div>

In a ui\_template (and possibly other ui nodes) you can use [Angular's number filters](https://www.w3schools.com/angular/ng_filter_number.asp)

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

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 February 2022 22:39 UTC](https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608/3 "2022-02-01T22:39:40Z")

</div>

Outstanding, thank you Andy.  
 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a2d91f06ab94360e31d88b15924f11e606ef393c.jpeg)

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

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [1 February 2022 22:52 UTC](https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608/4 "2022-02-01T22:52:15Z")

</div>

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](https://www.w3schools.com/angular/angular_filters.asp)

ps. nice weather presentation 👍

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 February 2022 22:59 UTC](https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608/5 "2022-02-01T22:59:41Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [2 February 2022 15:13 UTC](https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608/6 "2022-02-02T15:13:35Z")

</div>

Ohh nice! I hope you decide to share this.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [5 February 2022 17:51 UTC](https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608/7 "2022-02-05T17:51:52Z")

</div>

[Working demo.](https://discourse.nodered.org/t/compact-multi-location-weather-display/57833/5)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [19 February 2022 17:51 UTC](https://discourse.nodered.org/t/template-node-displaying-a-value-rounded-to-1dp/57608/8 "2022-02-19T17:51:54Z")

</div>

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