How to decide between template and ui-template nodes

Hello!

I'm fairly new to Node-RED and I need to send an email with basic HTML in a flow. However, it does have tables and some logic to hide a few elements if needed.

As I'd never used the mustache syntax, when I read that it was "logic-less" I assumed there would be no way to create loops for the table elements, or hide elements when needed.

So I looked into ui-template and the angular support seemed nice because the people that'll work on this flow later are already familiar with it. However, it seems tied to serving pages to a client which I don't need in this particular case, and also I couldn't find out how to get the final static HTML to output (I know it can send messages, I just don't know how to get the final HTML to be sent).

As I was in a hurry, I ended up creating a little monstrosity... I used the template node and made the loop with the flow itself.

Later on I learned that mustache can do loops and conditional statements and that I should've RTFM a bit more. So now I can kill the monstrosity and have a much cleaner flow. However, I'm still not sure about the best way to go and would like some advice from more experienced Node-RED users!

One advantage of using ui-template is that angular is known by other people that may work in the flow in the future. Another is that I would probably use it in any rendered HTML then and would've only one syntax instead of two. The problem is, I don't know how to use it to output the rendered HTML. The disadvantage would be to have to serve a webpage for it, but I could create a workaround for this to not be available outside.

The advantage of using the default template node is that it's a tool that actually fits this specific job nicely.

I'm leaning towards keeping the default template node.

Thanks in advance for any input! :slight_smile:

Hi @cadu

the ui_template node can only be used as part of a Node-RED Dashboard. It cannot be used to generate raw HTML that you then use in your flow.

For what you are doing, the core template node is the one to use.

Thanks @knolleary. BTW, congrats on the nice work :slight_smile:

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