# Passing message to next node using template syntax

**URL:** <https://discourse.nodered.org/t/passing-message-to-next-node-using-template-syntax/85377>\
**Category:** General\
**Created:** [9 February 2024 16:40 UTC](https://discourse.nodered.org/t/passing-message-to-next-node-using-template-syntax/85377 "2024-02-09T16:40:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iot.regenesis](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iot.regenesis/32/100846_2.png) [@iot.regenesis](https://discourse.nodered.org/u/iot.regenesis)\
**Post date:** [9 February 2024 16:40 UTC](https://discourse.nodered.org/t/passing-message-to-next-node-using-template-syntax/85377/1 "2024-02-09T16:40:31Z")

</div>

hi all forum members,

Not sure if the topic makes sense .. but I'll ask anyway 😉

This is the value I wanted to pass on to next node:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/4/940a5c8b03c80c94ce95d70a3d16e7d9007c1499.png)

.. could not get this working on the next node (EXEC node)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/2213e6fa0ab7a9c0d55eaf969e5cb1c7cea8ebc7.png)

I don't know if that's correct way to pass value, I've googled it but could not find similar example of it.  
Is it possible/proper to pass value like that?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [9 February 2024 17:56 UTC](https://discourse.nodered.org/t/passing-message-to-next-node-using-template-syntax/85377/2 "2024-02-09T17:56:05Z")

</div>

I believe the exec node does not allow mustache template.  
You could create the command prior and append it with msg.payload.  
there are many ways to do this of course.

Here is one example using the template node.

```auto
[{"id":"1194e34726faa84f","type":"inject","z":"e1ef5728e9206b4a","name":"","props":[{"p":"payload"},{"p":"topic","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"str","x":210,"y":620,"wires":[["8c67ed5a9667154f"]]},{"id":"8c67ed5a9667154f","type":"template","z":"e1ef5728e9206b4a","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"set_power {{{payload}}} -s powered {{#topic}}1{{/topic}}{{^topic}}0{{/topic}}","output":"str","x":380,"y":640,"wires":[["74ee6f08590cce85","0d37b44178b16b05"]]},{"id":"daf93507509ec81f","type":"inject","z":"e1ef5728e9206b4a","name":"","props":[{"p":"payload"},{"p":"topic","v":"false","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"str","x":210,"y":680,"wires":[["8c67ed5a9667154f"]]},{"id":"74ee6f08590cce85","type":"debug","z":"e1ef5728e9206b4a","name":"debug 2472","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":620,"wires":[]},{"id":"0d37b44178b16b05","type":"exec","z":"e1ef5728e9206b4a","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":550,"y":660,"wires":[[],[],[]]}]

```

You would not need the change node to convert the booleans doing it this way.

---

<div class="post-metadata">

**Author:** ![iot.regenesis](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iot.regenesis/32/100846_2.png) [@iot.regenesis](https://discourse.nodered.org/u/iot.regenesis)\
**Post date:** [10 February 2024 02:05 UTC](https://discourse.nodered.org/t/passing-message-to-next-node-using-template-syntax/85377/3 "2024-02-10T02:05:29Z")

</div>

thank you @E1cid

I've never used template node before, your example looks simple but took me sometime to understand. At least I know how to use the template node and mustache now 🙂

Anyway .. I've used function node to make the flow works ..

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/d/2dbb48dfac81a837ae5df8049222257a0a535db9.png)

Cheers!!

---

<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:** [24 February 2024 02:05 UTC](https://discourse.nodered.org/t/passing-message-to-next-node-using-template-syntax/85377/4 "2024-02-24T02:05:41Z")

</div>

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