Hacker News new | ask | show | jobs
by 0cf8612b2e1e 662 days ago
Could you elaborate? I think it’s fine? Although I have always subscribed to the “Two Scoops” philosophy and keep my templates as stupid as possible. Use a variable, simple conditions, etc. Anything more complex should be handled at a higher level.

Go templating on the other hand, that drove me bananas.

1 comments

I got used to React components, and after that templates feel a bit cumbersome and un-ergonomic in places.

I’ve been using Django templates since 2006. Jinja was designed after Django templates of that era, fixing their most glaring problems. Don’t remember the exact year when I started using Jinja a lot. Maybe 2013.

For example, a pure existence of an {% include %} tag. People use it, implicitly passing many arguments to some other template. Which makes it very hard to understand and change later.

Macros are not that pleasant to use, there are less features in macros then in Python functions, and tools support is much worse too (static analysis, formatting, etc).

Filters… why do I need to write `value|string` instead of `str(value)`?

Etc.

The benefit of filters is that they don’t share the namespace with the template context and I would argue are more readable.
Not sharing the same namespace is a benefit, I agree. Not a huge one, as I don’t name my variables “map”, “string” and similar anyway. And would not look favorably if any of my employees did that.