5 ms·
I seem to be in the minority but I'm not a fan of jinja2. I like mako better, I guess you have more leeway to do silly things but I never feel like I can't do w
by danmur 5y ago
I seem to be in the minority but I'm not a fan of jinja2. I like mako better, I guess you have more leeway to do silly things but I never feel like I can't do what I want.
- deleted 5y ago[deleted]
- memco 5y agoHaving never used Mako the appeal to me over Jinja is that it allows you to use real control structures. Jinja is a bit of a pain to debug and develop because it does some things slightly differently than you'd do in native Python so even though I can setup breakpoints and evaluate the application state I can't easily convert the code changes I make in the debugger back to the template. I get that there are reasons why Jinja and other templating systems guard against this, but it does have a cost.
- jxramos 5y agocan you detail the idea about real control structures, are you talking about if and elif and else clauses? Is there something partial about jinja's control structures? https://jinja.palletsprojects.com/en/3.0.x/templates/#list-of-control-structures https://jinja.palletsprojects.com/en/3.0.x/templates/#list-o...
- simonw 5y agoI've seen a large scale Mako codebase and the amount of business logic that had sneaked into the templates was horrifying - really made me double-down on my preference for limited template languages that help people avoid that temptation. I helped design Django's template language and I now think we took keeping it restrictive a bit too far though - these days I prefer working with Jinja because it has better support for complex expressions and lets you call functions within your templates. That does mean it requires a bit more discipline to use responsibly though, but being able to control which functions are exposed to the template context helps a lot there.
- wodenokoto 5y agoI hate jinja. I really don’t get it. So here’s a complaining reply, so you hopefully won’t feel as alone. When using jinja2 for website builders, it just feels like a poor version of old school php. I’ve also seen it used for generating json/yaml config files, which to me is absolutely bunkers compared to just building a dictionary in Python and exporting it.