3 ms·
Interpolation should have been added to the HTML specification over a decade ago. It's one of the many things the standards body has gotten wrong. This is some
by dimmke 3y ago
Interpolation should have been added to the HTML specification over a decade ago. It's one of the many things the standards body has gotten wrong.
This is something that literally every single framework, front-end and back-end has had to deal with in some way since the 90s. From chucking ugly <?php tags to more elegant solutions like curly braces.
Having one standard in the spec would standardize something that is currently done a million different ways.
- theamk 3y agoBut string interpolation is a small part of it. Think about formatting a shopping cart: you need interpolation, yes. But also a "for" loop (for iterating over item list), and "if" statements (to show "cart is empty" or item notes), and functions, like money pretty-printing, would be nice too. And don't forget the nested function-like blocks so one can embed standard design elements... This gets complex fast, I cannot imagine having something like this as a slow-moving spec.
- dimmke 3y agoI agree with you. I think Svelte and the syntax it uses to do everything you're describing, from iterating to interpolation should be part of the HTML spec.
- regularfry 3y agoIt's a standards producer/consumer disconnect. XSLT on XHTML documents was always the Right Way(tm), but XML got such a backlash it never stood a chance once HTML5 landed. Also, XSLT is horrible.
- wombatpm 3y agoXSLT is just XML with pattern matching and no side effects. Lisp-ish in a way That said XML is like violence, if it’s not solving you problems you need to use more.
- regularfry 3y agoXSLT feels like the fact that it's expressed in XML syntax is gratuitous meta-tomfoolery. It's like rather than thinking about the problem they grabbed the closest parser that happened be lying around, minding its own business. Mind you, to be fair, xml parsers are extremely convenient, and if you're going to make it part of a standard it makes sense to use something else you already know is going to be in that standard. I don't know if there was ever any user-facing tooling which made that a particularly good decision, but it certainly makes the language painful to read.
- regularfry 3y agoOn a related note, I do wonder if that XML backlash would ever have been so bad if we'd had the `</>` closing tags from SGML. Sure, it's no `)`, but then again, what is?
- jameshart 3y agoI think they also screwed up by calling it a ‘stylesheet language’. The idea of producing visual presentation by running XSL-T and then XSL-FO was the kind of thing that makes you think writing TeX macros might be easier. Hilariously over engineered for the problem users actually wanted to solve (making data driven web pages look pretty).
- hlandau 3y agoThis is a very good point, and I say that as someone who willingly chooses to use XSLT (I used to use it to generate my website before that got too unwieldy, and still use it for some things). It's a very natural proclivity of a language designer designing a template language for language X to want to find a way to articulate that template language in that same language X also. I think most engineers can't help but love ideas like that. It's probably the same reason everyone who creates a programming language wants to make a self-hosted compiler for it. In this case though, XML being a rather verbose and arguably limited semantic markup language for textual documents, it's an extraordinarily unergonomic choice for templating itself (in notable stark contrast to SXML combined with Lisp code, which is an example of homoiconicity between the structure being templated and the templating language works very well).
- oever 3y ago> Also, XSLT is horrible. XQuery can do everything XSLT can but with different syntax. XQuery 3 can also handle JSON. It's a clean way to generate well-formed XHTML.
- TylerE 3y agoHow would that work if html is to remain dumb?
- jameshart 3y agoHTML does now have <template>. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template https://developer.mozilla.org/en-US/docs/Web/HTML/Element/te...