# Trying to refresh the page in Dashboard Template node

**URL:** <https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551>\
**Category:** Dashboard\
**Created:** [2 June 2018 16:54 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551 "2018-06-02T16:54:40Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grendel61](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/grendel61/32/75_2.png) [@Grendel61](https://discourse.nodered.org/u/Grendel61)\
**Post date:** [2 June 2018 16:54 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/1 "2018-06-02T16:54:41Z")

</div>

Hi,

I’m relatively new to AngularJS, and I’m looking for some guidance on how to use the app controller inside an AngularJS app in a Dashboard Template Node. I want to reload the part of the page related to the data when new data comes in from $watcher.

My understanding of AngularJS is that I need to do something like this:

```
(async function($scope) {
    $scope.$watch('msg.payload', async function(payload,oldPayload) {
        
        // Do stuff

    })
    $scope.reloadRoute = function() {
        $route.reload()
    }
})(scope)

```

But, I get an error because $route hasn’t been defined as a function. I assume I need something like this from my research:

```
var app = angular.module("myApp", ["ngRoute"])
$scope.reload()

```

But, Node-Red Dashboard must create the app and probably the controller. **So how do I access it?**

---

<div class="post-metadata">

**Author:** ![davidcgu](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@davidcgu](https://discourse.nodered.org/u/davidcgu)\
**Post date:** [2 June 2018 19:31 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/2 "2018-06-02T19:31:17Z")

</div>

Most probably is not the answer you expect, but have you in mind the fact that you can force to reload the dashobard tab with the ui\_control node?

---

<div class="post-metadata">

**Author:** ![Grendel61](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/grendel61/32/75_2.png) [@Grendel61](https://discourse.nodered.org/u/Grendel61)\
**Post date:** [2 June 2018 20:36 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/3 "2018-06-02T20:36:02Z")

</div>

Thanks for the idea. I did try that at one point, but it didn’t seem to have an effect on an App in a template node. I think I need to do this in Angularjs

Best Regards,

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [2 June 2018 20:59 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/4 "2018-06-02T20:59:42Z")

</div>

You are correct the app is defined in the main part of the dashboard app so you don’t have access.

But you can update the template using `msg.template` which should reload it.

---

<div class="post-metadata">

**Author:** ![Grendel61](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/grendel61/32/75_2.png) [@Grendel61](https://discourse.nodered.org/u/Grendel61)\
**Post date:** [3 June 2018 16:12 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/5 "2018-06-03T16:12:36Z")

</div>

Can you provide an example, or point me to one, that would provide a guide on what to pass in msg.template.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 June 2018 10:03 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/6 "2018-06-09T10:03:08Z")

</div>

From the Template's 'Node Help'

> Using msg.template:  
> You can also define the template content via msg.template, so you can use external files for example.  
> Template will be reloaded on input if it has changed.  
> Code written in the Template field will be ignored when msg.template is present.

---

<div class="post-metadata">

**Author:** ![marcpouliot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcpouliot/32/4326_2.png) [@marcpouliot](https://discourse.nodered.org/u/marcpouliot)\
**Post date:** [20 December 2018 12:10 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/7 "2018-12-20T12:10:31Z")

</div>

I know this is an old post. But ...  
Can anybody provide an example, or point me to one, that would provide a guide on what (AND HOW) to pass in msg.template.

> **Using `msg.template` :**  
> **You can also define the template content via** `msg.template` , so you can use external files for example.  
> Template will be reloaded on input if it has changed.  
> Code written in the Template field will be ignored when `msg.template` is present.

I find the help "guide" not very "helping" since I still do not know to " **define the template content via msg.template**"....  
🙂  
thks

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 December 2018 13:46 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/8 "2018-12-20T13:46:30Z")

</div>

> [@marcpouliot](#):
>
> Can anybody provide an example, or point me to one, that would provide a guide on what (AND HOW) to pass in msg.template.

Before getting on to that do you know how to use the template node in the normal situation where you do not modify the template via a message?

---

<div class="post-metadata">

**Author:** ![marcpouliot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcpouliot/32/4326_2.png) [@marcpouliot](https://discourse.nodered.org/u/marcpouliot)\
**Post date:** [22 December 2018 17:12 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/9 "2018-12-22T17:12:18Z")

</div>

Hi, (thks for answering)  
I do not quite understand the

> the normal situation where you do not modify the template via a message?

For me, the normal situation, is modifying some status of the template via the incoming message (color, text etc)  
By the way,  
I use the \</\> template from the dashboard.  
I realize there is also a " { template " in the "function" tab. ( which uses mustache format) - I do not use this one.  
So, I just wanted to know how to use a js file (as stated in the info..), instead of changing the text in the \</\> template. Where do you set the file name ?? ....beats me.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 December 2018 22:13 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/10 "2018-12-22T22:13:44Z")

</div>

> [@marcpouliot](#):
>
> For me, the normal situation, is modifying some status of the template via the incoming message (color, text etc)

Doing that you are not modifying the template, you are just passing it data in the message. The earlier comments in the thread are referring to modifying the template text itself, I think.

---

<div class="post-metadata">

**Author:** ![hugobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugobox/32/2948_2.png) [@hugobox](https://discourse.nodered.org/u/hugobox)\
**Post date:** [23 December 2018 05:44 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/11 "2018-12-23T05:44:25Z")

</div>

To modify the template via a msg.template you would typically do: inject -\> file in node set to the template file you want to load - \> change node : move msg.payload to msg.template -\> ui\_template node

---

<div class="post-metadata">

**Author:** ![marcpouliot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcpouliot/32/4326_2.png) [@marcpouliot](https://discourse.nodered.org/u/marcpouliot)\
**Post date:** [23 December 2018 20:46 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/12 "2018-12-23T20:46:55Z")

</div>

Thanks again !  
I see this must be simple for you.... I still do not understand !!.... An **example** would be so nice...  
Let's say, I want to change the look of a LED not using Fa- icons since I do not find the ones I want... So I am experiencing with \</\> template... I have many of those on my page, I do not want to go through all of them when I find a better look... setting them once to a file, I won't need to rename the labels. This is what I use to organize the UI.

I will try here to include a simple flow to show that I want "what is in template" in a file "testFile.js" in "/home/pi/node-red-static". ...

I am not sure how to include a flow (code from clipboard) in a forum message. (hoping I am not offending anyone by doing this.)  
I realize that you probably already said what is necessary to understand...  
the flow is in the message ... the testFile is testfile.json which should be testFile.js.

## [testFile.json](https://discourse.nodered.org/uploads/short-url/zF18i3fKvosnqfhEdUprNQwrz91.json) (440 Bytes) _Modifying the current flow could be a way to finally make me understand?? 🙂_

I am trying to resend the code here.... ( it does not seem to work when I tried to re-import it.

```auto
    [
    {
        "id": "c9bcc0fb.7840c",
        "type": "tab",
        "label": "templateFile",
        "disabled": false,
        "info": "Trying to use a file instead of code int template node."
    },
    {
        "id": "87cb616b.17d4e",
        "type": "function",
        "z": "c9bcc0fb.7840c",
        "name": "nameLabel ColorText ID label",
        "func": "msg.color = (msg.payload === \"on\")?\"red\":\"lime\";\nmsg.textColor = \"white\";\nmsg.ID = \"blabla\";\nmsg.nameLabel =\"Text w LED\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 560,
        "y": 160,
        "wires": [
            [
                "2a47bd72.78a442"
            ]
        ]
    },
    {
        "id": "b8b01811.80e918",
        "type": "inject",
        "z": "c9bcc0fb.7840c",
        "name": "",
        "topic": "",
        "payload": "on",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 110,
        "y": 140,
        "wires": [
            [
                "14bd8760.3ed049"
            ]
        ]
    },
    {
        "id": "3f6df693.17a9fa",
        "type": "inject",
        "z": "c9bcc0fb.7840c",
        "name": "",
        "topic": "",
        "payload": "anything else",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 130,
        "y": 180,
        "wires": [
            [
                "1a306d5a.cd99a3"
            ]
        ]
    },
    {
        "id": "8ad524b0.806198",
        "type": "debug",
        "z": "c9bcc0fb.7840c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 970,
        "y": 160,
        "wires": []
    },
    {
        "id": "14bd8760.3ed049",
        "type": "ui_button",
        "z": "c9bcc0fb.7840c",
        "name": "",
        "group": "d52a3c14.46df2",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "green",
        "color": "",
        "bgcolor": "",
        "icon": "fa-fire",
        "payload": "asdf",
        "payloadType": "str",
        "topic": "",
        "x": 330,
        "y": 140,
        "wires": [
            [
                "87cb616b.17d4e"
            ]
        ]
    },
    {
        "id": "2a47bd72.78a442",
        "type": "ui_template",
        "z": "c9bcc0fb.7840c",
        "group": "d52a3c14.46df2",
        "name": "Porte Chambre",
        "order": 7,
        "width": "4",
        "height": "1",
        "format": "<div ng-bind-html=\"\"></div>\n<style>\n\n#{{msg.ID}} {\n stroke: none;\n fill: {{msg.color}};\n}\n#Ell1{\n stroke: none;\n fill: {{msg.color}};\n}\n\n</style>\n\n<svg>\n\n <circle\n style=\"CircleStyle\"\n id={{msg.ID}}\n cx=\"160\"\n cy=\"10\"\n r=\"10\" />\n <g font-family=\"Verdana\" font-size=\"medium\" >\n <text x=\"1\" y=\"15\" fill={{msg.textColor}} >\n{{msg.nameLabel}}\n </text>\n </g>\n</svg>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "templateScope": "local",
        "x": 800,
        "y": 160,
        "wires": [
            [
                "8ad524b0.806198"
            ]
        ]
    },
    {
        "id": "1a306d5a.cd99a3",
        "type": "ui_button",
        "z": "c9bcc0fb.7840c",
        "name": "",
        "group": "d52a3c14.46df2",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "red",
        "color": "",
        "bgcolor": "",
        "icon": "fa-fire",
        "payload": "on",
        "payloadType": "str",
        "topic": "",
        "x": 330,
        "y": 180,
        "wires": [
            [
                "87cb616b.17d4e"
            ]
        ]
    },
    {
        "id": "d52a3c14.46df2",
        "type": "ui_group",
        "z": "",
        "name": "Default",
        "tab": "5e70d158.dd523",
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "5e70d158.dd523",
        "type": "ui_tab",
        "z": "",
        "name": "tests",
        "icon": "dashboard"
    }
]

```

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [24 December 2018 14:34 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/13 "2018-12-24T14:34:39Z")

</div>

I would use the function template, taking care of configuring it as below. Note that I in this template I changed the way of using the mustache syntax: `fill: {{color}};` instead of `fill: {{msg.color}};` for example.

 ![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e1a7d3ee0e2d7374f6c69262d0dec55cc38d7544.png)

 ![r-02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f06a078874480bba060cb28a9d2847a2017440b9.png)

Flow:

```auto
[{"id":"f586239.38556e","type":"tab","label":"templateFile","disabled":false,"info":"Trying to use a file instead of code int template node."},{"id":"c092aec7.38777","type":"function","z":"f586239.38556e","name":"nameLabel ColorText ID label","func":"msg.color = (msg.payload === \"on\")?\"red\":\"lime\";\nmsg.textColor = \"white\";\nmsg.ID = \"blabla\";\nmsg.nameLabel =\"Text w LED\";\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":100,"wires":[["18e366bd.d16da9","63156636.c909c8"]]},{"id":"1870738b.efe41c","type":"inject","z":"f586239.38556e","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":80,"wires":[["271df20.d352a0e"]]},{"id":"85d79eba.e4876","type":"inject","z":"f586239.38556e","name":"","topic":"","payload":"anything else","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":140,"wires":[["f0a5fcd0.087cd"]]},{"id":"271df20.d352a0e","type":"ui_button","z":"f586239.38556e","name":"","group":"be88e3ed.c6c8e","order":0,"width":0,"height":0,"passthru":false,"label":"green","color":"","bgcolor":"","icon":"fa-fire","payload":"asdf","payloadType":"str","topic":"","x":270,"y":80,"wires":[["c092aec7.38777"]]},{"id":"f0a5fcd0.087cd","type":"ui_button","z":"f586239.38556e","name":"","group":"be88e3ed.c6c8e","order":0,"width":0,"height":0,"passthru":false,"label":"red","color":"","bgcolor":"","icon":"fa-fire","payload":"on","payloadType":"str","topic":"","x":270,"y":140,"wires":[["c092aec7.38777"]]},{"id":"18e366bd.d16da9","type":"template","z":"f586239.38556e","name":"","field":"template","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\n<style>\n\n#{{ID}} {\n stroke: none;\n fill: {{color}};\n}\n#Ell1{\n stroke: none;\n fill: {{color}};\n}\n\n</style>\n\n<svg>\n\n <circle\n style=\"CircleStyle\"\n id=blabla\n cx=\"160\"\n cy=\"10\"\n r=\"10\" />\n <g font-family=\"Verdana\" font-size=\"medium\" >\n <text x=\"1\" y=\"15\" fill={{textColor}} >\n{{nameLabel}}\n </text>\n </g>\n</svg>","output":"str","x":680,"y":160,"wires":[["30543cda.7e5894"]]},{"id":"30543cda.7e5894","type":"ui_template","z":"f586239.38556e","group":"be88e3ed.c6c8e","name":"","order":0,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":840,"y":160,"wires":[[]]},{"id":"63156636.c909c8","type":"debug","z":"f586239.38556e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"color","x":740,"y":100,"wires":[]},{"id":"be88e3ed.c6c8e","type":"ui_group","z":"","name":"Default","tab":"1d6699ca.dab0e6","disp":true,"width":"6","collapse":false},{"id":"1d6699ca.dab0e6","type":"ui_tab","z":"","name":"tests","icon":"dashboard"}]

```

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [24 December 2018 15:38 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/14 "2018-12-24T15:38:49Z")

</div>

Now, if you want to move the template to a file then this modified flow should work.

 ![r-03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/72e9b558f950d1f558965c28cd3959f9ba218bbf.png)

Flow:

```auto
[{"id":"a0b35f90.70dca","type":"tab","label":"templateFile","disabled":false,"info":"Trying to use a file instead of code int template node."},{"id":"17ced148.b65c0f","type":"function","z":"a0b35f90.70dca","name":"nameLabel ColorText ID label","func":"msg.color = (msg.payload === \"on\")?\"red\":\"lime\";\nmsg.textColor = \"white\";\nmsg.ID = \"blabla\";\nmsg.nameLabel =\"Text w LED\";\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":100,"wires":[["8a1368e4.140278","8982b4f6.3dd128"]]},{"id":"9c0e413f.18928","type":"inject","z":"a0b35f90.70dca","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":80,"wires":[["470a95ac.df4b8c"]]},{"id":"d17b70e.a1ada9","type":"inject","z":"a0b35f90.70dca","name":"","topic":"","payload":"anything else","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":140,"wires":[["c70b731a.65ddd"]]},{"id":"470a95ac.df4b8c","type":"ui_button","z":"a0b35f90.70dca","name":"","group":"be88e3ed.c6c8e","order":0,"width":0,"height":0,"passthru":false,"label":"green","color":"","bgcolor":"","icon":"fa-fire","payload":"asdf","payloadType":"str","topic":"","x":270,"y":80,"wires":[["17ced148.b65c0f"]]},{"id":"c70b731a.65ddd","type":"ui_button","z":"a0b35f90.70dca","name":"","group":"be88e3ed.c6c8e","order":0,"width":0,"height":0,"passthru":false,"label":"red","color":"","bgcolor":"","icon":"fa-fire","payload":"on","payloadType":"str","topic":"","x":270,"y":140,"wires":[["17ced148.b65c0f"]]},{"id":"73fd282f.cb4388","type":"ui_template","z":"a0b35f90.70dca","group":"be88e3ed.c6c8e","name":"","order":0,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":940,"y":180,"wires":[[]]},{"id":"8a1368e4.140278","type":"debug","z":"a0b35f90.70dca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"color","x":900,"y":100,"wires":[]},{"id":"8982b4f6.3dd128","type":"file in","z":"a0b35f90.70dca","name":"Read file","filename":"C:\\Users\\OCM\\.node-red\\static\\nrfiles\\template-1.txt","format":"utf8","chunk":false,"sendError":false,"x":440,"y":180,"wires":[["cd8e5ed9.6d6f2"]]},{"id":"608bbd5b.4ee524","type":"debug","z":"a0b35f90.70dca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":890,"y":260,"wires":[]},{"id":"5631331a.0253fc","type":"template","z":"a0b35f90.70dca","name":"","field":"template","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"","output":"str","x":780,"y":180,"wires":[["73fd282f.cb4388","608bbd5b.4ee524"]]},{"id":"cd8e5ed9.6d6f2","type":"change","z":"a0b35f90.70dca","name":"","rules":[{"t":"set","p":"template","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":180,"wires":[["5631331a.0253fc"]]},{"id":"be88e3ed.c6c8e","type":"ui_group","z":"","name":"Default","tab":"1d6699ca.dab0e6","disp":true,"width":"6","collapse":false},{"id":"1d6699ca.dab0e6","type":"ui_tab","z":"","name":"tests","icon":"dashboard"}]

```

---

<div class="post-metadata">

**Author:** ![marcpouliot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcpouliot/32/4326_2.png) [@marcpouliot](https://discourse.nodered.org/u/marcpouliot)\
**Post date:** [12 February 2019 15:37 UTC](https://discourse.nodered.org/t/trying-to-refresh-the-page-in-dashboard-template-node/551/15 "2019-02-12T15:37:42Z")

</div>

Hi Andrei, I took me a while before I could look at your proposed solution.... Thank you so much !!!  
I can now modify one file for the behavior of many LEDS with text.  
I discovered the mustache syntax...  
Note: I put the ReadFile+set msg.template+template nodes in a subflow. Added the msg.filename in the preceeding function to set the parameters.  
I also modify the id=blabla in the text file to id = {{ID}} to allow for different TextLEDs with different values.  
thanks again for your patience and detailed explanation.  
I now understand... by looking at the different debug stages why the msg.template has to be set.  
the ReadFile puts the raw file in the msg.payload, gets copied to the msg.template, and an indication for the mustache syntax is put just before the \</\>template can be instantiated.  
I will try to include my example flow just in case someone encounters the same problems I had.[ThanksAndrei.txt](https://discourse.nodered.org/uploads/short-url/8oLPR5G8zxRBShQOxrPIewICIlC.txt) (6.6 KB)  
I try the infamous three backquotes to include the code...(does not seem to work anymore ??) (grrr...) I cannot find how to include images or codes properly in this forum.... Is this documented anywhere ? sorry...  
`[{"id":"2f87f2e.075dc0e","type":"subflow","name":"TextLed","info":"","in":[{"x":80,"y":80,"wires":[{"id":"ccdee70f.bcd108"}]}],"out":[{"x":780,"y":80,"wires":[{"id":"d21da5fa.73c138","port":0}]}]},{"id":"ccdee70f.bcd108","type":"file in","z":"2f87f2e.075dc0e","name":"Read file","filename":"","format":"utf8","chunk":false,"sendError":false,"x":220,"y":80,"wires":[["e3e1ba24.247838"]]},{"id":"e3e1ba24.247838","type":"change","z":"2f87f2e.075dc0e","name":"","rules":[{"t":"set","p":"template","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":80,"wires":[["d21da5fa.73c138"]]},{"id":"d21da5fa.73c138","type":"template","z":"2f87f2e.075dc0e","name":"Use Mustache","field":"template","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"","output":"str","x":620,"y":80,"wires":[[]]},{"id":"2c930137.26a03e","type":"tab","label":"ThanksAndrei","disabled":false,"info":"Trying to use a file instead of code in template node."},{"id":"a54070a4.bb245","type":"function","z":"2c930137.26a03e","name":"SetTextLed","func":"msg.color = (msg.payload === \"on\")?\"red\":\"lime\";\nmsg.textColor = \"white\";\nmsg.ID = \"blabla\";\nmsg.nameLabel =\"Text w LED\";\nmsg.filename=\"/home/pi/node-red-static/testTemplate.js\"\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":40,"wires":[["91e6991d.6918b8"]]},{"id":"f64ce53e.ecc4d8","type":"inject","z":"2c930137.26a03e","name":"","topic":"","payload":"anything else","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":80,"wires":[["8c13aa25.fc29e8"]]},{"id":"8c13aa25.fc29e8","type":"ui_button","z":"2c930137.26a03e","name":"","group":"75da5bf1.7a8244","order":2,"width":0,"height":0,"passthru":false,"label":"red1","color":"","bgcolor":"","icon":"fa-fire","payload":"on","payloadType":"str","topic":"","x":250,"y":80,"wires":[["a54070a4.bb245"]]},{"id":"115a9bec.935f74","type":"ui_template","z":"2c930137.26a03e","group":"75da5bf1.7a8244","name":"TemplateAndrei","order":3,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":820,"y":180,"wires":[[]]},{"id":"4e8db3e4.e5765c","type":"file in","z":"2c930137.26a03e","name":"Read file","filename":"","format":"utf8","chunk":false,"sendError":false,"x":640,"y":40,"wires":[["37fc2068.51ac4"]]},{"id":"9a2af295.d030d","type":"template","z":"2c930137.26a03e","name":"Use Mustache","field":"template","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"","output":"str","x":1040,"y":40,"wires":[[]]},{"id":"37fc2068.51ac4","type":"change","z":"2c930137.26a03e","name":"","rules":[{"t":"set","p":"template","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":40,"wires":[["9a2af295.d030d"]]},{"id":"5d452461.766bcc","type":"function","z":"2c930137.26a03e","name":"SetTextLED","func":"msg.color = (msg.payload === \"on\")?\"red\":\"lime\";\nmsg.textColor = \"white\";\nmsg.ID = \"blabla2\";\nmsg.nameLabel =\"Text2 w LED\";\nmsg.filename=\"/home/pi/node-red-static/testTemplate.js\"\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":360,"wires":[["7a0b020d.98778c"]]},{"id":"9d88c36d.48e71","type":"ui_template","z":"2c930137.26a03e","group":"75da5bf1.7a8244","name":"TemplateAndrei2","order":6,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":850,"y":440,"wires":[[]]},{"id":"28496c98.6a2fa4","type":"inject","z":"2c930137.26a03e","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":90,"y":320,"wires":[["da512f0b.8f26b"]]},{"id":"77acd785.629848","type":"inject","z":"2c930137.26a03e","name":"","topic":"","payload":"anything else","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":380,"wires":[["319b0339.9bbfec"]]},{"id":"da512f0b.8f26b","type":"ui_button","z":"2c930137.26a03e","name":"","group":"75da5bf1.7a8244","order":4,"width":0,"height":0,"passthru":false,"label":"green2","color":"","bgcolor":"","icon":"fa-fire","payload":"asdf","payloadType":"str","topic":"","x":260,"y":320,"wires":[["5d452461.766bcc"]]},{"id":"319b0339.9bbfec","type":"ui_button","z":"2c930137.26a03e","name":"","group":"75da5bf1.7a8244","order":5,"width":0,"height":0,"passthru":false,"label":"red2","color":"","bgcolor":"","icon":"fa-fire","payload":"on","payloadType":"str","topic":"","x":250,"y":380,"wires":[["5d452461.766bcc"]]},{"id":"c252c974.042508","type":"inject","z":"2c930137.26a03e","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":90,"y":40,"wires":[["1f980983.29f2a6"]]},{"id":"1f980983.29f2a6","type":"ui_button","z":"2c930137.26a03e","name":"","group":"75da5bf1.7a8244","order":1,"width":0,"height":0,"passthru":false,"label":"green1","color":"","bgcolor":"","icon":"fa-fire","payload":"asdf","payloadType":"str","topic":"","x":260,"y":40,"wires":[["a54070a4.bb245"]]},{"id":"c27a5f89.ff43a","type":"comment","z":"2c930137.26a03e","name":"3NodesInaSubFlow+Contents of Read file","info":"One could put the three nodes in subflow.\nI changed ID=blabla in the file for id={{ID}} to provide for \nmultiple templates with different values.\n\nContents of the read file..\n<style>\n\n#{{ID}} {\n stroke: none;\n fill: {{color}};\n}\n</style>\n\n<svg>\n <circle\n //style=\"CircleStyle\"\n id={{ID}}\n cx=\"120\"\n cy=\"15\"\n r=\"10\" />\n <g font-family=\"Verdana\" font-size=\"medium\" >\n <text x=\"1\" y=\"20\" fill={{color}}>\n{{nameLabel}}\n </text>\n </g>\n</svg>","x":760,"y":120,"wires":[]},{"id":"91e6991d.6918b8","type":"subflow:2f87f2e.075dc0e","z":"2c930137.26a03e","x":650,"y":180,"wires":[["115a9bec.935f74"]]},{"id":"f28b5361.69d1e","type":"template","z":"2c930137.26a03e","name":"Use Mustache","field":"template","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"","output":"str","x":980,"y":360,"wires":[["9d88c36d.48e71"]]},{"id":"8e092e42.adaba","type":"change","z":"2c930137.26a03e","name":"","rules":[{"t":"set","p":"template","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":360,"wires":[["f28b5361.69d1e"]]},{"id":"7a0b020d.98778c","type":"file in","z":"2c930137.26a03e","name":"Read file","filename":"","format":"utf8","chunk":false,"sendError":false,"x":580,"y":360,"wires":[["8e092e42.adaba"]]},{"id":"75da5bf1.7a8244","type":"ui_group","z":"","name":"Default","tab":"82aa62ad.00185","disp":true,"width":"6","collapse":false},{"id":"82aa62ad.00185","type":"ui_tab","z":"","name":"testsAndrei","icon":"dashboard"}]`
