# Output two attributes in the template

**URL:** <https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983>\
**Category:** Dashboard\
**Created:** [20 December 2018 12:58 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983 "2018-12-20T12:58:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Georg25](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@Georg25](https://discourse.nodered.org/u/Georg25)\
**Post date:** [20 December 2018 12:58 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/1 "2018-12-20T12:58:05Z")

</div>

Hi,  
how can I output msg.xx and msg.yy simultaneously in a template?

```
> <div design="row" >
> <p><b><font size="7" color="red"><marquee scrollamount="15" scrolldelay="10" direction="left" style="background-color: yellow !important;">{{msg.door}}&{{msg.help}}</marquee></font></b></p>
> 
> </div>

```

This code displays either msg.door or msg.help in my marquee, but never both at the same time.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [20 December 2018 13:05 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/2 "2018-12-20T13:05:47Z")

</div>

Are you sure they are both present in one message you are sending to the node?  
Check with a debug node to make sure that both exist in a message.

---

<div class="post-metadata">

**Author:** ![Georg25](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@Georg25](https://discourse.nodered.org/u/Georg25)\
**Post date:** [20 December 2018 13:12 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/3 "2018-12-20T13:12:38Z")

</div>

No, they are not both present in one message, how do i get both in a message?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [20 December 2018 13:18 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/4 "2018-12-20T13:18:22Z")

</div>

Well that depends where they are coming from. You could try looking at the join node.  
or look at how to store data  
[https://nodered.org/docs/writing-functions#storing-data](https://nodered.org/docs/writing-functions#storing-data)

Where one flow writes the value for say help and then the flow where door is set picks up the last "help" value from the stored data.

---

<div class="post-metadata">

**Author:** ![Georg25](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@Georg25](https://discourse.nodered.org/u/Georg25)\
**Post date:** [20 December 2018 13:56 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/5 "2018-12-20T13:56:48Z")

</div>

I can not stand it, with the join node I can pack both payloads in one, but for my display in the marquee this does not help me, because if msg.door is high and msg.help is not, msg.door will be displayed. If msg.door is high and msg.help becomes active 10 seconds later, only msg.help will be displayed. both are only displayed if they are activated at the same time

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [20 December 2018 14:05 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/6 "2018-12-20T14:05:36Z")

</div>

Which is why I also suggested you look at how to store data.

It sounds as if you want both values to be stored. So that when new message comes in  
for door it picks up the latest value of help  
and if a new help message comes in it picks up the latest version of door.

See

```auto
[{"id":"bc95c600.8a7ff","type":"inject","z":"44c6969d.6be6c","name":"","topic":"","payload":"Door1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":125.5,"y":121,"wires":[["e74f067f.68d2e8"]]},{"id":"40776dfa.949a94","type":"inject","z":"44c6969d.6be6c","name":"","topic":"","payload":"Help1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":136,"y":260,"wires":[["527b8184.c9bcc8"]]},{"id":"c04f22bc.ece308","type":"inject","z":"44c6969d.6be6c","name":"","topic":"","payload":"Door2","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":126,"y":160,"wires":[["e74f067f.68d2e8"]]},{"id":"2a297a3f.5793fe","type":"inject","z":"44c6969d.6be6c","name":"","topic":"","payload":"Help2","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":135,"y":301,"wires":[["527b8184.c9bcc8"]]},{"id":"e74f067f.68d2e8","type":"change","z":"44c6969d.6be6c","name":"","rules":[{"t":"set","p":"door","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":272.5,"y":141,"wires":[["6eed31e.adb2c5"]]},{"id":"527b8184.c9bcc8","type":"change","z":"44c6969d.6be6c","name":"","rules":[{"t":"set","p":"help","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":279,"y":278,"wires":[["20dcad07.a5a60a"]]},{"id":"6eed31e.adb2c5","type":"change","z":"44c6969d.6be6c","name":"","rules":[{"t":"set","p":"door","pt":"global","to":"door","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":499.5,"y":140,"wires":[["3d0d745f.6cadcc"]]},{"id":"20dcad07.a5a60a","type":"change","z":"44c6969d.6be6c","name":"","rules":[{"t":"set","p":"help","pt":"global","to":"help","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":495,"y":277,"wires":[["7f16357b.4d0cdc"]]},{"id":"3d0d745f.6cadcc","type":"change","z":"44c6969d.6be6c","name":"","rules":[{"t":"set","p":"help","pt":"msg","to":"help","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":734,"y":138,"wires":[["4747696d.be2c88"]]},{"id":"7f16357b.4d0cdc","type":"change","z":"44c6969d.6be6c","name":"","rules":[{"t":"set","p":"door","pt":"msg","to":"door","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":724,"y":276,"wires":[["4747696d.be2c88"]]},{"id":"4747696d.be2c88","type":"template","z":"44c6969d.6be6c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"These are the two values in one message: {{door}}&{{help}}","output":"str","x":881.5,"y":206,"wires":[["7d2010bf.72b2e8"]]},{"id":"7d2010bf.72b2e8","type":"debug","z":"44c6969d.6be6c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":926.5,"y":350,"wires":[]}]

```

This only works after you have a value for each, but there are ways around that as well.

---

<div class="post-metadata">

**Author:** ![Georg25](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@Georg25](https://discourse.nodered.org/u/Georg25)\
**Post date:** [21 December 2018 07:11 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/7 "2018-12-21T07:11:23Z")

</div>

Thanks that works great 😃

how do I get it now so that there is some distance between the two texts?  
with "hspace" it does not work just as well if I insert spaces in between

---

<div class="post-metadata">

**Author:** ![Georg25](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@Georg25](https://discourse.nodered.org/u/Georg25)\
**Post date:** [21 December 2018 07:33 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/8 "2018-12-21T07:33:02Z")

</div>

I have it, with &nbsp; a blank is output

---

<div class="post-metadata">

**Author:** ![Georg25](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@Georg25](https://discourse.nodered.org/u/Georg25)\
**Post date:** [4 January 2019 07:35 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/9 "2019-01-04T07:35:18Z")

</div>

Is there a way to dynamically change the background color of the marquee, for example with the "colour picker"?

I have not gotten it yet.

When I type

`

\<marquee scrollamount = "15" scrolldelay = "10" direction = "left" style = "background-color: {{msg.colour}}! Important;"\>

`  
nothing works anymore

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [4 January 2019 15:10 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/10 "2019-01-04T15:10:15Z")

</div>

Are you trying to use that `{{msg.colour}}` mustache substitution inside the core `template` node, or in `ui_template`? The former supports mustache syntax, but the latter does not...

If you want that substitution to happen inside `ui_template`, you will have to use an Angular `ng-style` directive instead, so whenever the `msg` object changes, its new values are updated in the DOM (somthing like this, untested):

```auto
<marquee scrollamount="15" scrolldelay="10" direction="left" ng-style="background-color: {{msg.colour}} !important;">

```

BTW, your html should not have the extra spaces around the `=` in your attributes...

---

<div class="post-metadata">

**Author:** ![Georg25](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@Georg25](https://discourse.nodered.org/u/Georg25)\
**Post date:** [7 January 2019 07:20 UTC](https://discourse.nodered.org/t/output-two-attributes-in-the-template/5983/11 "2019-01-07T07:20:39Z")

</div>

That do not work, but thanks for your help 😀
