top | item 41369129

(no title)

brucecrust | 1 year ago

ha man I hate Jinja. Nothing against this or Rust, just from working in Flask I have borderline nightmares. That might say more about my team that the framework though.

discuss

order

bityard|1 year ago

Every templating engine has to find a balance between doing what you need it to do, and letting you write business logic in the template itself. (Hey there, PHP.) That said, it's possible to write pathlogical templates in just about anything.

I've used Jinja a lot and always thought that it struck just about the right balance.

The docs are also way better than they used to be.

murkt|1 year ago

I’ve been using Jinja2 for years and years, probably around a decade now. I don’t remember any other docs?

IshKebab|1 year ago

The answer is not to use a templating engine. TSX is the gold standard here IMO. Using it with https://fresh.deno.dev/ is soooo much nicer than old school templates.

0cf8612b2e1e|1 year 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.

murkt|1 year ago

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.

singhrac|1 year ago

I have the opposite memory :) I remember writing complex applications in Flask and it just worked right away, and as our performance / complexity grew it kind of kept up because it was very modular.

golergka|1 year ago

I worked on a project that implemented static type checking for dbt projects, which are made of SQL templated with jinja and some yaml configs. I'm not sure if I hate it, but it certainly was fun.

snarkyturtle|1 year ago

Wait until you have to work in Mustache/Handlebars, you'd love Jinja