Hacker News new | ask | show | jobs
by STRiDEX 721 days ago
I have to do "real" ssr every once in a while via the django jinja html files we have to send emails. It makes me want to die coming from our nice typescript react SPA frontend. Every object is a mystery and jinja syntax is functional but terrible to maintain and of course you're suddenly using tables because it's an email.

I'd rather every element be a div than do one minute of editing those stupid jinja files.

3 comments

It sounds like your issue is with the syntax of Jinja, and the hellscape of HTML email. I'm not sure how 20 MB of inscrutable JavaScript would help, considering it's also just template rendering with extra steps (bonus: using the user's CPU cycles and power instead of your own).
> It sounds like your issue is with the syntax of Jinja, and the hellscape of HTML email. I'm not sure how 20 MB of inscrutable JavaScript would help, considering it's also just template rendering with extra steps

20MB of inscrutable JavaScript allows you to have a) a sane structured component system where you can actually build up UIs compositionally rather than a flat glorified string substituter (i.e. not actually "just template rendering"), and b) the control and abstractions needed to make good UIs out of nested tables.

you can compose UI on the backend without string substituting. Are you under the impress that JSX is some sort of thing exclusive to Frontend?
> you can compose UI on the backend without string substituting.

Sure, but you're still going to be using "20 MB of inscrutable JavaScript". (Unless you use Wicket, but I'm not sure that's an option for emails, and would likely trigger the same complaints anyway). I mean, I hope you're not using the component style rendering layer for Python that I published ~10 years ago, because I haven't maintained it, and as far as I know there aren't any others.

20 MB JavaScript is much less bad when you’re not sending it to the client.
And all this for marketing emails nobody reads anyway.
> jinja

As a home assistant user, jinja in yaml files is hot steaming ass.

Every time I read the jinja manual I want to cry. And a small part of me dies in side. It's like a templating language designed to get even with the person who microwave a tuna fish sandwich in the office, for lunch, daily... That some how leaked out to the web.

There are different template engines for SSR, with drastically different syntax. I've never written any Python, but in my own opinion, Smarty for PHP and Twig-compatible ones for many different languages are the best.

While generating any moderately complex HTML on the front end is a pain in the ass for me. I prefer avoiding it. If I need to request some data from the server to dynamically update the page with, I just make that endpoint return some server-side-rendered HTML that I insert wherever it needs to go.