# How to dynamically set HTML attribute value using UI template mustache syntax?

**URL:** <https://discourse.nodered.org/t/how-to-dynamically-set-html-attribute-value-using-ui-template-mustache-syntax/37860>\
**Category:** Dashboard\
**Created:** [22 December 2020 01:10 UTC](https://discourse.nodered.org/t/how-to-dynamically-set-html-attribute-value-using-ui-template-mustache-syntax/37860 "2020-12-22T01:10:15Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 December 2020 16:43 UTC](https://discourse.nodered.org/t/how-to-dynamically-set-html-attribute-value-using-ui-template-mustache-syntax/37860/4 "2020-12-22T16:43:18Z")

</div>

> [@Herold](#):
>
> using only a subflow

If you are doing what I am thinking, there are issues putting UI nodes in a subflow (I forget what - but it doesnt work as expected)

> [@Herold](#):
>
> My goal is mainly to factorize UI templates

Perhaps this is of some help - something i did some time back...

> [@Adding \`output\` function to buttons designed in \`template\` node](https://discourse.nodered.org/t/adding-output-function-to-buttons-designed-in-template-node/25591/54):
>
> Andrew, some home work for you tomorrow... I have updated the code to also handle repeat buttons - try to implement them. PS, backup your flows first smiley Dont worry, the idea is exactly the same (add some attributes to a button then magic happens automatically) Visual Demo note... holding VOL buttons sends repeat messages the lock button is font awesome (the rest are material design) The flow [{"id":"f4fac1e9.e93e4","type":"ui\_template","z":"e1dfad68.fee2a","group":"be17…

there are lots of hint and clues in there that might prove useful (like moving away from directly specifying colours - using classes instead, etc)

> [@Herold](#):
>
> i've got parse error with Devtools on:  
> `<button onclick="{{{msg.my_onclickfunction}}}"></button>`

That shouldn't even get through to the browser. Share your code if you want someone to look closer.

---

_[View the full topic](https://discourse.nodered.org/t/how-to-dynamically-set-html-attribute-value-using-ui-template-mustache-syntax/37860)._
