How to program a if-instruction in the template node by using html

If you want to render an html element based on some msg.payload data, you can use a ui_template node. For instance, assuming you can have a relative url string in your payload, you can insert it into an <img> src attribute using this syntax:

<img style="width: 300px; height: 200px;" src="{{msg.payload}}">

Every time a new payload arrives, the image src is updated, and the new image appears on the dashboard (or a broken image icon, if the url is not valid).

1 Like