A while back, I wrote a templating engine (MIT License), which I mostly use for small side projects, either static or ssr generated. Simplicity is one of the main goals.
I'll be happy to answer any questions. The main goal for sharing it is to simply get some feedback.
Best, Emil
Except it’s missing the ability to hydrate components on the client and re-render.
I use htmx for as much of my network requests and UI updating as possible as it’s faster to implement features, faster the render and easier to reason around than a SPA front end and JSON response backend - there’s a chance the OP is in a similar boat.
The downside to a JS SSR driven app is the backend templating situation isn’t as expressive as JSX and can feel a bit limiting.
Hopefully OP will chime in and correct of confirm my assumptions.
I've been using it for small projects and I didn't want to be bothered with all of the setup required to get jsx/tsx transpilation in place.
Another important reason was that I wanted a tool that would let me reach high results in lighthouse, and that's not something you'd get with other tools quickly. Critical css out of the box seemed to be approach that worked for me in this scenario.
Not every webapp needs client side hydration. It’s very often wasted CPU cycles on a page that’ll be unloaded three seconds later. Personally I’m happy to see projects like this that live outside the monoculture.
(I do that for my framework mininext https://github.com/spirobel/mininext would be happy to receive feedback, other view points on this :-)
I like my tools to have as much types generated from context as possible (types from OpenApi, from graphql or from sql queries) and was looking to build a tool like that for handlebars. Idea being that it would tell you which types the template variables used so you could avoid stupid errors at compile time.
It seamed handlebars could provide an AST, but it was kinda hard to used so I scrapped the effort.
Maybe this would be more condusive?
1. You could add a jsdoc comment per component, let your tool read it and treat it as the source of truth 2. The template is just a js file, so you could parse it, get the params of the fn and try to deduce the types based on the usage 3. You could use typescript and export types 4. Serialize/normalize data before passing to the templating engine
This looks like what I wanted in a templating language
It is mature and feature rich. I like that the expressions can be plain js and it is not coupled with html.
Another project on the HN homepage at the moment happens to do this: https://www.val.town/v/maxm/staticChess
const { renderToString } = require('react-dom/server')
renderToString(<ul>{[1, 2, 3].map(n => <li>{n}</ul>)}</div>)
Granted, you have to configure it so that JSX is allowed in your JS. For example, by running your code as `tsx server.js`, but I find it so much better than Pug/Nunjucks of yore that it makes up for that downside.Could this also work in the browser?
Otherwise you might end up reimplementing those.
The intentions of the tool were the server side and static use cases and I didn't plan to use it on the client side.