3 ms·
Cool, good to know. What makes JSX such a good templating engine?
by webmaven 4y ago
Cool, good to know. What makes JSX such a good templating engine?
- bluefirebrand 4y agoIt's personal preference of course, but imo JSX is just a very clean way of writing frontends. Easy composability, easy data bindings which don't have to be two-way if you don't want. My sense with many templating engines is they are trying to crowbar programming functionality into HTML and always comes across clunky. It's usually a separate language from your server code entirely. Inline If statements and For Loops embedded in your HTML. And composing a template with a subtemplate is often clumsy. With JSX you just write your normal JavaScript or Typescript and output JSX. Then the JSX is turned into HTML and returned to the browser. But of course I'm not familiar with every HTML templating library out there, but I've used a few and I really love working with JSX.
- webmaven 4y agoMy own favorite syntax(es) are TAL, TALES, and METAL (Template Attribute Language, TAL Expression Syntax, and Macro Expansion TAL). There are many implementations in various languages. The OG implementation was in Python as part of the Zope: https://pagetemplates.readthedocs.io/en/latest/tal.html https://pagetemplates.readthedocs.io/en/latest/tal.html These days I reach for Chameleon, another Python implementation: https://chameleon.readthedocs.io/ https://chameleon.readthedocs.io/ I'm aware of at least five implementations for JS: template-tal, jstal, Distal, DomTal, ZPT-JS.
- bluefirebrand 4y agoCool, thanks for the recommendations! I don't write a lot of python anymore but I'll check these out.