# Suffix for text output

**URL:** <https://discourse.nodered.org/t/suffix-for-text-output/89879>\
**Category:** Dashboard\
**Tags:** dashboard-2\
**Created:** [30 July 2024 12:36 UTC](https://discourse.nodered.org/t/suffix-for-text-output/89879 "2024-07-30T12:36:44Z")\
**Posts on this page:** 1\
**Showing post:** 24

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [30 July 2024 15:05 UTC](https://discourse.nodered.org/t/suffix-for-text-output/89879/24 "2024-07-30T15:05:22Z")

</div>

> [@joepavitt](#):
>
> Quite possibly - although I really don't like the readability of JSONata - I find it very unintuitive.

100%! A man after my own heart!

> [@joepavitt](#):
>
> Point acknowledged on the `toFixed` though - any thoughts @Steve-Mcl?

> [@Colin](#):
>
> Unfortunately if you want to show `{{payload.toFixed(2)}} °C`, which was also possible in the D1 nodes,

This is not something that Mustache supports - but (IIRC) a ~~hack~~ workaround. In fact, I am pretty sure @dceejay has mentioned this recently.

One solution would be the use of filters (like the angular filters). There is such a concept for vue ([example](https://talkingtech.io/filters-in-vue-js/)) but I remember reading recently they were dropped from Vue 3.

Vue [has written](https://v3-migration.vuejs.org/breaking-changes/filters.html) the recommended approach now is to use `computed` however this does not help in cases like this where you are not coding but there is a 2nd alternative suggestion `"globalProperties"` in that link that _might_ be useful (assuming the D1 mustache-ish syntax support is added to D2).

In short, it would mean we may be able to offer support for things like `{{ $filters.formatNumber(payload, { fixed: 2, suffix: ' °C' }) }}`

The thing is, it isn't really low-code nor is it JavaScript. Its not even JSONata, its another awkward workaround. Don't get me wrong I want a better way of formatting values but I am not certain the original D1 way was the best and so mimicking it in d2 may be worse current solution.

* * *

### outlandish ideas:

# 1

How about a dashboard config section that accepts JS code where a user can add to a list of "filters". This set of filters would then be presented on the node and the user selects the appropriate filter for the data. Of course there would be a default set like "2 decimal places", "uppercase", "title case" etc but users could then generate their own "divide by 100 and suffix with ' volts'" filter.

# 2

How about (forgive me) permitting the option of `msg.` and `JSONata` for the fields that require formatting? Easier to implement BUT harder for users (and a chain around the necks of D2 devs for ever more)

# 3

Something else?

---

_[View the full topic](https://discourse.nodered.org/t/suffix-for-text-output/89879)._
