Populate html template from a file

I'm trying to load the template node with an incoming template from a file node.

When I pass the file payload to the template, I see mustache curly braces {{ xyz }} on the page.

If I take this same template code and copy it into the node template section... It works fine.

There is something about msg.template, I try to attach the code to this, but I don't get anything.

My goal is to remotely open and save the template file from my design tool [Pinegrow], and have node-red template open these templates without needing to manually copy and paste the code to the template node each time.

Is there something I'm missing?

Probably easier to use the static folder feature (see settings.js). Read the file, replace any dynamic variables and write to the static folder.

:+1: Thank you

So, Just to clarify...
Passing msg.template [as a string of an html/mustache template] into the template node won't render as if it were placed in the template node's Edit template node's code editor?

I don't know the answer to that I'm afraid. I've never actually needed to try that. In fact, it hadn't even occurred to me :grinning:

But then I did write uibuilder so I use that when I want a web app :wink:

Incorrect.

The template node WILL render msg.template

The input msg.template is...
This is msg.topic >> {{topic}} << This is msg.payload >> {{payload}} << This is msg.test>> {{test}} <<

The output is ...
image


Here is a demo...

[{"id":"9b5f87bc.872af8","type":"inject","z":"4b3f21a3.ba434","name":"","props":[{"p":"template","v":"This is msg.topic >> {{topic}} <<    This is msg.payload >> {{payload}} <<    This is msg.test>> {{test}} <<","vt":"str"},{"p":"payload"},{"p":"test","v":"HELLO FROM msg.test","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"HELLO FROM msg.topic","payload":"HELLO FROM msg.payload","payloadType":"str","x":740,"y":3160,"wires":[["c5155da0.d0176"]]},{"id":"c5155da0.d0176","type":"template","z":"4b3f21a3.ba434","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"","output":"str","x":950,"y":3160,"wires":[["7184f9ec.be18b8"]]},{"id":"7184f9ec.be18b8","type":"debug","z":"4b3f21a3.ba434","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1170,"y":3160,"wires":[]}]
2 Likes

... I totally forget about your web builder. I need to revisit it. Was neato when I was looking at it a few times.

1 Like

Thank you for verifying, I was able to double check this,
and seems that I wasn't converting msg.payload to the msg.template ? Seems to be working now.

Thank again!

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