html-is-a-tree
28 points by matklad
28 points by matklad
As a heads up to the author, janet-html permits precisely the same hiccup (but you don't need ' before). The implementation is perhaps less elegant, but it's more standards compliant with doctype versions and replaces e.g. & etc. besides handling text. Here is an more extensive example. You'd just need to spit the result to a file.
I found this hiccup SSG also: https://github.com/swlkr/speakeasy
This feels a lot like what Dave Thompson's Haunt does. My own website/blog uses it, and it's quite nice. The page/post/etc templates are functions that return SXML, and you insert the page body structurally into the template: https://git.sr.ht/~jfred/website/tree/master/item/theme.scm#L65
You can write your posts in Skribe: https://git.sr.ht/~jfred/website/tree/master/item/posts/weve-got-you.skr
...or in Markdown: https://git.sr.ht/~jfred/website/blob/master/posts/structural-scheme.md
Or in whatever other format you want, if you write a reader for it. A reader is just a function that turns the input into an SXML tree.
It's very flexible, and I've had a lot of fun using it. :)
This feels a lot like what Dave Thompson's Haunt does.
The author does mention it:
I found haunt, which seemed to do what I wanted, but I wasn't able to install it so I gave up.
SXML is remarkably elegant for "SSG scripting" (if that term even makes sense). It's almost like JSX, just with the "compiler" using the same system and environment as the language as a whole.
The author does mention it
Oops, yeah, I missed that in the post 😅
SXML is remarkably elegant for "SSG scripting" (if that term even makes sense). It's almost like JSX, just with the "compiler" using the same system and environment as the language as a whole.
Yeah. Big fan of getting as far away from string templating as I can, as someone who works with a bunch of devops tooling in my day job. Working with structured data instead makes me very happy. And I'm a Lisp-lover, so SXML feels pretty natural :)
Feels like there's a lot of crossover here with my work. I've started authoring my blog posts in CSTML, and I'm getting most of the same benefits using many of the same techniques. I can embed arbitrary code and whitespace safely, unlike markdown. I can have inline code snippets with syntax highlighting too, which markdown doesn't support.
I don't have anything against Janet, but I do think I have an advantage in that a lot more people know JS, making it easier to get people to adopt it as the template processing language.
I took me a few minutes to remember how to find this from the depths of my memory. It's like 100 lines of js