Hacker News new | comments | show | ask | jobs | submit login

> logic in the presentation layer

Sometimes logic belongs in the presentation layer (if it is related to showing the information to the user).

Take the "if" tag for example. It doesn't support complex conditions (values can only be tested for values of truth, and it doesn't support parenthesis to define precedence) and adding an if block inside another if block is just ugly. To get around this, you usually construct a boolean value inside your view, but it often happens that this value is only relevant for one template (i.e. HTML). And if your view also returns JSON / YAML, that's not clean.

Also, QuerySets are lazy by default, and it goes beautifully hand in hand with caching template fragments, and this works for me since I usually can't cache whole pages (some fragments are more dynamic than others). But if you move template logic in your view, then you're going to have to worry about caching in your view too, duplicating logic.

Also, the if tag doesn't support "ifelse" ... what's up with that? Are designers too stupid to use ifelse properly?

Yes, I know you can create your own tags, but it would've been nice if these things worked out of the box, and it's not OK to define a tag that's not reusable (like in the case of a complex "if" condition that can't be expressed in the template directly), because that's extra work that doesn't pay off.

And since we are talking about designer-friendliness, how are designers going to understand working with such non-standard tags all over the place?

Now, thus far the Django templates haven't been much of a problem for me, but the projects I worked on in Django have been pretty simple. But I know they are not enough so I'm currently looking for alternatives (fortunately it is easy to replace).

"Yes, I know you can create your own tags..."

Yeah, this is usually the response you get when you mention stuff like the missing ifelse, and it's totally ridiculous. Why should I go about reinventing this stuff? The whole reason I'm using a framework is to speed up development. You also risk everyone inventing it on their own in their own way, so now if you go try to work on someone else's project, maybe they've implemented it, maybe they haven't, and even if they have, it's probably not going to be the same way you implemented it, so now you're re-learning again for no added benefit.

Applications are open for YC Winter 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact