Hi Mike,
If you care to check the uibuilder code, there are some good examples of this.
This node has a fairly simple example: node-red-contrib-uibuilder/editor.js at main · TotallyInformation/node-red-contrib-uibuilder (github.com)
The main uibuilder node is a lot more complex and has many functions: node-red-contrib-uibuilder/editor.js at main · TotallyInformation/node-red-contrib-uibuilder (github.com)
NB: For convenience, I have a workflow that splits each node's html file into multiple parts. A Gulp watch process sticks them back together as I save. That's why the files shared are a bare js file.