3 ms·
What is your suggestion besides string templates? Writing out the html syntax tree? No thanks!
by bruce343434 3y ago
What is your suggestion besides string templates? Writing out the html syntax tree? No thanks!
- psychoslave 3y agoSomething like Pug[1] is really nice to avoid all the xml cluttering. [1] https://pugjs.org/ https://pugjs.org/
- marcomourao 3y agoAs a mediocre developer at best, I love PUG but I'm a bit afraid about the lack of updates.
- psychoslave 3y agoIndeed https://github.com/pugjs/pug/issues/3339 https://github.com/pugjs/pug/issues/3339
- gdprrrr 3y agoMany frameworks do exactly that, including React and https://github.com/vanjs-org/van https://github.com/vanjs-org/van
- naasking 3y agoI think Mithril was the first one to pioneer this.
- hparadiz 3y agoLol. 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.
- naasking 3y agoPioneer 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.
- chrismorgan 3y agoNah, 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/54310121b442974721115f93666234a200f5c7e4/eg/cgi/nph-clock.cgi 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 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.
- PurpleRamen 3y agoA 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.
- jimbokun 3y agoS-expressions!
- jameshart 3y agoThis amounts to saying ‘but I want to be able to generate invalid HTML!’
- theamk 3y agoNo, this amounts to saying "I don't care enough about accidentally generating HTML, I want to use faster + more convenient method instead"