finds.dev← search

// the find

creationix/haml-js

★ 899 · JavaScript · MIT · updated Jun 2021

Haml ported to server-side Javascript. This is a traditional server-side templating language. Tested with node-js

A port of Ruby's HAML templating syntax to server-side JavaScript, built for Node.js. It compiles indentation-based markup to a reusable template function, with the expectation you compile once at startup and call the result millions of times. Aimed at developers who already know HAML and want the same syntax outside of a Rails stack.

The compile-once/execute-many model is the right call — generating a JavaScript function from the template means repeated renders are just string concatenation with no parsing overhead. The test suite is unusually thorough for a project this age: each feature has a paired .haml and expected .html file, so you can see exactly what the parser is supposed to produce. The whitespace control operators (> and <) are a thoughtful addition that Ruby HAML handles awkwardly. The `customEscape` option for sharing a single escape function across compiled templates shows real production thinking.

Last commit was 2021 and the project is effectively unmaintained — open issues go unanswered and there is no package maintainer actively reviewing PRs. The executable JavaScript blocks (the `-` prefix) are a footgun: the 'outdent to output from within a JS block' rule is counterintuitive and errors from misaligned braces produce cryptic failures. There is no async support whatsoever — if your template helpers need to fetch data, you have to resolve everything before rendering, which rules out a whole class of use cases. The `escapeHtmlByDefault` being off by default is the wrong safe default; XSS is the common failure mode and you have to opt into safety.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →