3 ms·
Syntax for loops and conditionals introducing scopes to your document may work fine for plain text documents, but in my experience it turns structured documents
by gorelyy 5y ago
Syntax for loops and conditionals introducing scopes to your document may work fine for plain text documents, but in my experience it turns structured documents like HTML in unreadable mess very fast. I don't know why it's a de facto standard for template engines to make it this way.
I came up with the idea of attaching conditions and loop specifications directly to XML tags, and in my opinion it significantly improves readability. I couldn't find any alternative with similar syntax, so I've implemented it myself. It's also in C++, although it works as a transpiler, and templates are needed to be compiled. It can be found here: https://github.com/kamchatka-volcano/hypertextcpp https://github.com/kamchatka-volcano/hypertextcpp
- tannhaeuser 5y agoI'm agreeing with everything you said, but still I don't know why it's a defacto standard for template "engines" targetting HTML or other markup to invent ad-hoc syntax rules involving Unix shell-like $s and/or curly-braces and/or dotted paths ;) When SGML, since the begin of times, has entities/entity references (plus CDATA/RCDATA marked sections) for exactly that purpose. Plus, can actually encode/quote expanded text in a context-dependent way (eg attributes vs elements) and prevent or allow expansion of replacement text into <script> directed by allowed content models, and prevent other injections using HTML-aware templating.
- WalterGR 5y agoit's a defacto standard for template "engines" targetting HTML or other markup to invent ad-hoc syntax rule Totally. My hypothesis: people enjoy writing templating engines, which is why there are so many. And people especially enjoy inventing their own programming languages. Templating engines are the perfect place for a web developer to dip their toes as gently as desired into language creation, in a format that’s kind of fun and is also immediately relevant and useful.