3 ms·
I really don't like Jinja. The syntax is not for me and there's often three different ways of building the same thing. I find it a bit confusing. Recently I st
by pietz 2y ago
I really don't like Jinja. The syntax is not for me and there's often three different ways of building the same thing. I find it a bit confusing.
Recently I started using JinjaX (https://jinjax.scaletti.dev/ https://jinjax.scaletti.dev/), which is weirdly amazing. I think the comparison on the homepage explains it quite well. It feels like what Jinja always should have been and and the multiple ways of doing the same thing converge into one syntax in JinjaX.
I really hope the project gains more traction.
- murkt 2y ago> JinjaX components are simple Jinja templates. You use them as if they were HTML tags without having to import them: easy to use and easy to read. …and impossible to understand and keep track of what goes where. No, thanks. Components are a good idea, and no imports is a horrible idea.
- adontz 2y agoDo I understand JinjaX correctly, that it's specifically for HTML templates, not text templates in general?
- pietz 2y agoYes
- krick 2y agoIDK. I always though Jinja is the best templating engine and was surprised by your complaints and the Jinja sample on that website. What doesn't he like? Looks totally legit... After reading JinjaX sample, I see the point. I would agree that it's much cleaner... If not for the fact he uses capitalized tags to distinguish between templates and html. I hate it. First off, it just throws me off, I cannot tell at the glance anymore where is the real text, and where is templating voodoo-magic. How do I find the source files fot layout and pagination? Right, I just have to know the convention. Second, it's remotely justifiable and can be attributed to a matter of getting used to only if it produces html. Templating engines are not restricted to html. It could be producing markdown, it could be producing XML. If only the author of this library restrained himself to be less funky and not introduce any ambiguous idioms, it would be pretty perfect. But as it is, I don't think I could use it.
- pietz 2y agoDifferent tastes, I guess. It's the same syntax that many JavaScript Frontend frameworks like react and Svelte use. I find it much cleaner. When using Jinja with HTMX you also run into trouble that it doesn't nicely support partials. You could use the jinja_partials library but I just find JinjaX so much more pleasant.
- the_mitsuhiko 2y agoFor what it's worth MiniJinja lets you render individual blocks if you so desire: https://docs.rs/minijinja/latest/minijinja/struct.State.html#method.render_block https://docs.rs/minijinja/latest/minijinja/struct.State.html...
- the_mitsuhiko 2y agoI don’t think that Jinja is the right way to build HTML heavy anything. Look at JSX for that. However I do find it interesting how this is a constant back and forth. I remember when the template engine that everybody in Python used was kid (precursor to genshi) which was XML based and looked a lot like vue/jsx does today. Back in the day people did not like it at all because designers found it hard to work with. Now the situation is a bit different but what do I know where we land in 10 years. It feels like a constant cycle ;)
- pietz 2y agoI think JinjaX was inspired by JSX. Obviously, there's a huge delta, but my "HTML heavy" problems are nicely solved with JinjaX