Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What is your suggestion besides string templates? Writing out the html syntax tree? No thanks!


A generic solution for handling structures, built into the language's themselves, not just some hidden lib that mostly nobody knows. I mean most modern languages come with some XML-parsers, and often they also come with some more or less useful XML-generator. Add them as a first class-citizen, pimp them up and allow them to barf out all kind of tree-like structure which are similar enough and shove it in peoples faces to animate them to use it.

I mean it basically worked with JSON too.


S-expressions!


Many frameworks do exactly that, including React and https://github.com/vanjs-org/van


I think Mithril was the first one to pioneer this.


Nah, it’s waaaaay older than that. It’s been done from the beginning of machine-produced HTML.

The probably slightly newer aspect is producing an intermediate representation that is then serialised to HTML, though I think that’s still going to be back in the ’90s. But the oldest examples I know of (while I was yet a small child) used functions and methods to produce serialised HTML strings directly, which was more efficient (at least in the languages in question) and also allowed you to mingle with string templating.

Perl’s CGI.pm let this example be written no later than 1997 (no idea when it was actually written, can’t be bothered searching harder for older than CGI.pm 2.32): https://github.com/Perl/perl5/blob/54310121b442974721115f936...

For stuff that worked on the frontend, it’s still way older, though it tended more to XML-based stuff like XSLT (… which still works in browsers now, e.g. https://chrismorgan.info/blog/tags/meta/feed.xml is an Atom feed but the <?xml-stylesheet?> processing instruction is basically a pointer to the file for the browser to use to convert it to HTML which it then renders). But there were definitely things in this vein even on the frontend in active use more than five years before Mithril, though I can’t be specific as my memory is fuzzy as I wasn’t paying much attention to it all back then.


Lol. I saw PHP libraries doing this 15 years ago.

Literally cringing as I read the readme. We decided over a decade ago that writing HTML with code is rediculous but somehow it comes up again and again.

A designer shouldn't need to code JavaScript to edit your design.


Pioneer this in the JS/client-side rendering world of course. Mithril is about 10 years old, so in the same ballpark.

Web applications aren't just HTML though, that's why code might be a more appropriate format.

You can argue that designers need better tools to edit structured markup in other formats, but that doesn't entail that HTML should be the default format. For instance, something like repl.it for mithril or similar that immediately renders the output so you can see the results would be useful.


Something like Pug[1] is really nice to avoid all the xml cluttering.

[1] https://pugjs.org/


As a mediocre developer at best, I love PUG but I'm a bit afraid about the lack of updates.



This amounts to saying ‘but I want to be able to generate invalid HTML!’


No, this amounts to saying "I don't care enough about accidentally generating HTML, I want to use faster + more convenient method instead"




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: