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

**URL:** https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111
**Category:** General
**Created:** [11 October 2021 23:48 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111 "2021-10-11T23:48:53Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [11 October 2021 23:48 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111/1 "2021-10-11T23:48:54Z")

</div>

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

Example:

```auto
[{"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:

```auto
this
is
a
test

```

---

<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: [12 October 2021 00:00 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111/2 "2021-10-12T00:00:25Z")

</div>

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 />`

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [12 October 2021 00:03 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111/3 "2021-10-12T00:03:05Z")

</div>

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?

---

<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: [12 October 2021 00:04 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111/4 "2021-10-12T00:04:46Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [12 October 2021 00:06 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111/5 "2021-10-12T00:06:45Z")

</div>

Sorry. I think I now understand it.

Alas while chasing this _problem_ I've found more.... ☹

~~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!~~

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [12 October 2021 00:29 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111/6 "2021-10-12T00:29:17Z")

</div>

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

```auto
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

---

<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: [12 October 2021 00:32 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111/7 "2021-10-12T00:32:24Z")

</div>

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

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

```

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [12 October 2021 00:34 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111/8 "2021-10-12T00:34:29Z")

</div>

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

![Screenshot from 2021-10-12 11-32-58](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/13ef6d1db5df63322fbcc0e6ac3b306561171b49.png)

Code:

```auto
[{"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:

```auto
{"_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`

---

<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: [11 December 2021 00:34 UTC](https://discourse.nodered.org/t/how-to-do-cr-in-a-template-node/52111/9 "2021-12-11T00:34:41Z")

</div>

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