Show HN: Boxwood – simple templating engine for JavaScript, in JavaScript
59 points| emilos | 1 year ago |github.com
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
ricardobeat|1 year ago
Except it’s missing the ability to hydrate components on the client and re-render.
[1] https://github.com/Raynos/mercury
simonbarker87|1 year ago
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.
madeofpalk|1 year ago
afavour|1 year ago
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.
javajosh|1 year ago
spirobelv2|1 year ago
(I do that for my framework mininext https://github.com/spirobel/mininext would be happy to receive feedback, other view points on this :-)
seer|1 year ago
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?
emilos|1 year ago
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
zeroq|1 year ago
MatthiasPortzel|1 year ago
martinbaun|1 year ago
This looks like what I wanted in a templating language
lf-non|1 year ago
It is mature and feature rich. I like that the expressions can be plain js and it is not coupled with html.
hombre_fatal|1 year ago
Another project on the HN homepage at the moment happens to do this: https://www.val.town/v/maxm/staticChess
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.supriyo-biswas|1 year ago
evbogue|1 year ago
Could this also work in the browser?
emilos|1 year ago
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.
unknown|1 year ago
[deleted]
neverokay|1 year ago
wetpaws|1 year ago
[deleted]
jesperancinha|1 year ago
[deleted]