How to do <CR> in a `template` node

I've looked quickly but am not quite understanding it and/or I can't apply it to what I have.

Example:

[{"id":"b0ec15c6f3951031","type":"inject","z":"65c9b63cb09879a0","name":"","props":[{"p":"a","v":"This ","vt":"str"},{"p":"b","v":"is","vt":"str"},{"p":"c","v":"a","vt":"str"},{"p":"d","v":"test","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":2270,"wires":[["4ca7961a7d0a7082"]]},{"id":"4ca7961a7d0a7082","type":"template","z":"65c9b63cb09879a0","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{a}}\\n{{b}}\\n{{c}}\\n{{d}}","output":"str","x":330,"y":2270,"wires":[["ec1f22b098bede33"]]},{"id":"ec1f22b098bede33","type":"debug","z":"65c9b63cb09879a0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":2270,"wires":[]}]

How do I get it to show as:

this
is
a
test

Just press enter (WYSIWYG)

Edit...
However, if you intend on sending this to be rendered in HTML, you'll probably want to do a break <br />

Um, sorry.

Ok, saw your edit.

I'm not understanding how to do it.
Could you indulge me and show me with the small script I posted?

Are you expecting to see a new line in the debug or in dashboard output?

Use the string <br /> instead of a new line or \n in the template if it is to be rendered in HTML

1 Like

Sorry. I think I now understand it.

Alas while chasing this problem I've found more.... :frowning:

And I've just realised that template won't work as I am parsing multiple parts of the message and not just the msg.payload.
ARGH!

I tried the WYSIWYG and it worked at that level, but not at the GUI side/end. :frowning:
So the template node is like this:

A/C in
{{time}}
Maximum {{max}}
Average {{average}}
Minimum {{min}}

But when it is displayed it is all one line.

How do I put the <br /> into the template?
More WYSIWYG

Just type those exact characters in the template. It's standard a html element.

A/C in <br />
{{time}} <br />
Maximum {{max}} <br />
Average {{average}} <br />
Minimum {{min}}

Strange, when I do that, I see/get this on the GUI side of things:

Screenshot from 2021-10-12 11-32-58

Code:

[{"id":"cfeb88a4.fc562","type":"template","z":"a3bd09a.b852978","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"A/C in <br />\n{{time}} <br />\nMaximum {{max}} <br />\nAverage {{average}} <br />\nMinimum {{min}} <br />","output":"str","x":510,"y":1580,"wires":[["ef4b7eaf.3063f","6a19476d.ac68d"]]},{"id":"6a19476d.ac68d","type":"ring-buffer","z":"a3bd09a.b852978","name":"","capacity":"11","order":"new-to-old","sendOnlyIfFull":false,"pushAfterClear":false,"extra":false,"perTopic":false,"x":760,"y":1530,"wires":[["bc7d09ea.3db358"]]},{"id":"bc7d09ea.3db358","type":"ui_template","z":"a3bd09a.b852978","group":"a1c9fadd.c2df8","name":"Daily readings","order":0,"width":"5","height":"6","format":"<table id=\"table\" border=\"1\">\n <tr>\n <th>Daily readings</th> \n </tr>\n <tbody>\n <tr ng-repeat=\"row in msg.payload track by $index\">\n <td class=\"text\" >{{row}}</td>\n </tr>\n </tbody>\n</table>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":950,"y":1530,"wires":[[]]},{"id":"a1c9fadd.c2df8","type":"ui_group","name":"Daily stuff","tab":"22b3809f.04cca","order":5,"disp":true,"width":"5","collapse":false},{"id":"22b3809f.04cca","type":"ui_tab","name":"History","icon":"dashboard","order":6,"disabled":false,"hidden":false}]

Message going in:

{"_msgid":"7ee8ecb6.2945e4","max":31,"topic":"TEMPERATURE/AC_in","qos":0,"retain":false,"settings":{"input":"2021-10-12T00:30:31.817Z","input_format":"","input_tz":"Australia/Sydney","output_format":"YYYY-MM-DD HH:mm:ss","output_locale":"en_AU","output_tz":"Australia/Sydney"},"time":"2021-10-12 11:30:31","_event":"node:acb3a212.0ac178","average":24,"min":20,"payload":"31\n24\n20"}

SORRY, you will need ring-bugger to load that code
node-red-contrib-ring-buffer

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