3 ms·
> Haml, Pug, and JSX are not template languages even though they can output HTML. That's nonsense, unless we go by your idiosyncratic definition of what a temp
by lioeters 3y ago
> Haml, Pug, and JSX are not template languages even though they can output HTML.
That's nonsense, unless we go by your idiosyncratic definition of what a template language is ("fancy string interpolation").
> Haml (HTML Abstraction Markup Language) is a templating system that is designed to avoid writing inline code in a web document and make the HTML cleaner.
> Pug – robust, elegant, feature rich template engine for Node.js
> JSX is an XML-like syntax extension to ECMAScript without any defined semantics.
OK, I'd agree that JSX is not strictly a template language.
But in the end, all of these compile down to HTML. Not by string interpolation, but as a language that is parsed into a syntax tree, then rendered into HTML properly with an internal understanding of valid structure.
YAML with templating is fancy string interpolation, it's not a template language (or at least a poorly implemented one).
- neallindsay 3y agoI am aware that Haml and Pug call themselves template languages, but they are not. In a template language, the source is a "template" that has some special syntax to fill in some bits. I don't think that's a very idiosyncratic definition. Pretty much any programming language can output a bunch of text, but most of them are not template languages. Java has XMLBuilder, but that doesn't make it a template language for outputting XML. But PHP is a template language, even though it's not recommended to use it that way anymore.
- lioeters 3y agoWell, it's true that Haml calls itself a "templating system", and Pug uses the term "template engine". That's 3 out of 3, you win. ;) PHP is a scripting language that is also a template processor, but I wouldn't call it a template language. So we disagree on several points, but no big deal. A big disadvantage of PHP, in relation to your original point about "fancy string interpolation", is that it does not natively understand the target output HTML syntactically and structurally.
- lioeters 3y agoSorry, reading over my comment, I sounded more antagonistic than I meant to be. After all, we're here to enjoy discussion and not to battle against each other. As an aside, on another post yesterday, I had a pleasant surprise about "templating" in life itself. > The familiar distinction between software and hardware loses its meaning in living cells. We propose new ways to study the phylogeny of metabolisms, new astronomical ways to search for life on exoplanets, new experiments to seek the emergence of the most rudimentary life, and the hint of a coherent testable pathway to prokaryotes with template replication and coding. https://arxiv.org/abs/2401.09514 https://arxiv.org/abs/2401.09514 Maybe DNA is the original templating language. (Hopefully with more sophistication than fancy string interpolation.)