4 ms·
I am a heavy user of Go's html/template library. The reason is that it allows me to not write Javascript. With vanilla JS you have to translate to JSON, then b
by carom 3y ago
I am a heavy user of Go's html/template library. The reason is that it allows me to not write Javascript.
With vanilla JS you have to translate to JSON, then build elements in the front end.
The solution to building elements in JS is to use a framework, but compiling Javascript just never sat right with me. It's like ok, now I have an incomprehensible bundle of minified JS and I probably need to run a JS backend if I don't want to go insane.
Alternatively, you can skip all of that and just template.
I'm excited for htmx but haven't used it yet. Simplicity wins. LAMP stack was great for its simplicity. Go monoliths are a modern solution.
- r3trohack3r 3y agoI’ve been using <template> to avoid the whole “create DOM elements in JS” thing, and it’s been working well so far. I wrote a little wrapper class to help with it: https://github.com/retrohacker/template https://github.com/retrohacker/template
- carom 3y agoI use that, is there a better pattern than doing a query selector to put the values in the correct places?
- Spivak 3y agoYou're conflating two things, dynamically creating HTML is great and lets you avoid JS in a lot of cases. It's whether you should treat your HTML document as the tree of nodes that it is in your programming language or treat it like a string. https://github.com/Knio/dominate https://github.com/Knio/dominate is a Python lib that implements this principal.