3 ms·
Far to simplistic. There is a reason Django is introducing range checking and simple logic into their template statements. How often do you specify something l
by enjo 16y ago
Far to simplistic.
There is a reason Django is introducing range checking and simple logic into their template statements. How often do you specify something like:
"If the amount owed is more than $100, make it red in the table"
That's not a question of separation of view/logic in my mind. It's a question of formatting. Forcing the view to resolve it down to a simple boolean statement results in a lot of cruft in the view layer that really doesn't belong there. It is just as evil to move presentation logic into a view as it is the other way around.
- ubernostrum 16y ago"If the amount owed is more than $100, make it red in the table" Well, my usual advice on this goes back to the first time I encountered someone pushing a similar situation. In that case he was showing government safety ratings for cars, and if the rating was above a certain level wanted to show a special graphic because that got it some special certification. Rather than try to force that logic into a template, I suggested giving the relevant model a "meets_certification_standard()" method, since that's the sort of thing you'd probably want to reuse for more than just presentation. And in your case I'd bet a similar approach would be the best solution.
- wvenable 16y agoMakes sense but a lot of decisions are much less "important" than that as some are purely about the rendering and don't have many meaning beyond it.