3 ms·
Clean, meaningful syntax! Great job! Edit: Why spread the ugliness of "endif" and "endblock"? Why not just "end"? Why have the unnatural "elif" as well?
by nikolay 11y ago
Clean, meaningful syntax! Great job!
Edit: Why spread the ugliness of "endif" and "endblock"? Why not just "end"? Why have the unnatural "elif" as well?
- the_mitsuhiko 11y ago> Edit: Why spread the ugliness of "endif" and "endblock"? Why not just "end"? Why have the unnatural "elif" as well? Not the developer but I did not remove endif for twig or jinja either coming from Django. Reasons for it: it becomes a lot more readable in the templates and it avoids lots of debug headache due to accidentally deleting things. It's already hard enough to debug template code sometimes but this way at least it's very quickly clear what the problem is. What would you use instead of elif? `{% else if %}` is in no way nicer than `{% elif %}`. I picked `elif` in Jinja because it's what Python uses and that's where Jinja is at home.
- e12e 11y agoNot affiliated with the project, but my take on this is either have a really simple block syntax, like Smalltalk "[ block ... ]" (ed: Or use only indentation, like python), or have semantically meaningful start/end. To take eg: html, I always find stuff like: <div class="navigation"> <div class="dropdown" id="misc"> ... </div> (... imagine a few hundred lines here) </div> <!-- text body? navigation? --> ... tends to get messy after a lot of editing and re-editing. Now this is just an example, with html5 we take a step back towards SGML/XML, and can use <article> so that </article> means "end article" (but which one?) and not "end navigation". Stuff like this easily gets out of hand with complicated meta-programming/inclusion/"transclusion". Say you import a footer, and then needs to debug the output. What is that "}" supposed to close? (This is true both for generating eg: java code, and for generating various templates/document types).