Am 03.05.2011 um 18:27 schrieb Phui Hock:
> Or, in a sane world:
>
> if x = {{ x }}, y = {{ y }}, {{ x }} + {{ y }} = {{ x_plus_y_res }}
> if x = {{ x }}, y = {{ y }}, {{ x }} * {{ y }} = {{ x_star_y_res }}
>
> and so on.
>
> While it is a common consensus that logic should never be in the template,
> the "solution" on the other hand is inconvenient at best.
>
> I must admit the examples are badly written and do not reflect the actual
> problem. The point here though, is that a general purpose math tag should be
> available by default. *The* math tag may be too flexible for its own good. If
> we have a dumber solution, I'm fine with that so long it supports the
> simplest cases, and that would be + - * / % min max and ().
FWIW, here are some concrete use-cases for math in templates:
* __mul__: Display a value of 0.42 as 42%.
* __neg__/__abs__: Display the absolute value and signum of a number separately.
* log: Display a number on a logarithmic scale.
* floor/ceil: Display floored or ceiled values.
I'd still be -1 regarding a {%math%} tag. The cleanest solution would be proper
support for common operators mixed with a set of default filters for primitive
functions (e.g log, floor, ceil, abs).
__
Johannes
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.