A couple years ago I started this small project for doing "old style" server templates but in a much more modern way and wanted to share it here. I'd appreciate any feedback you might have or any ideas to improve it if you have any.
I know nowadays doing "old style" templates is pretty out of fashion for many of us, but when working just myself on some side projects I felt like using a full blown modern "SPA" framework such as React or Vue was overkill, so I opted for doing plain old server templates with Stimulus.js sprinkles for the client side interactivity.
I tried EJS, Handlebars, Nunjucks, and a few others but after having enjoyed the support you get for TypeScript, Intellisense, syntax highlighting, autoformatting and other benefits that you get when using JSX, I felt like the existing templating solutions were way too out of date.
So I gave it a spin and ended up building this. It looks a bit like JSX and it's actually inspired in lit-html, except it's simplified to the maximum (implementation is about 70 lines) and works both in the browser and on the server.
This are lots of JS templating libraries that use tagged literals. It would be odd to release a templating library in 2023 that didn't use tagged literals.
2 comments
[ 2.1 ms ] story [ 12.4 ms ] threadA couple years ago I started this small project for doing "old style" server templates but in a much more modern way and wanted to share it here. I'd appreciate any feedback you might have or any ideas to improve it if you have any.
I know nowadays doing "old style" templates is pretty out of fashion for many of us, but when working just myself on some side projects I felt like using a full blown modern "SPA" framework such as React or Vue was overkill, so I opted for doing plain old server templates with Stimulus.js sprinkles for the client side interactivity.
I tried EJS, Handlebars, Nunjucks, and a few others but after having enjoyed the support you get for TypeScript, Intellisense, syntax highlighting, autoformatting and other benefits that you get when using JSX, I felt like the existing templating solutions were way too out of date.
So I gave it a spin and ended up building this. It looks a bit like JSX and it's actually inspired in lit-html, except it's simplified to the maximum (implementation is about 70 lines) and works both in the browser and on the server.
Thanks for any feedback.
NPM package: https://www.npmjs.com/package/html-string
Github repo: https://github.com/msurdi/html-string