On Tue, May 3, 2011 at 3:57 PM, Johannes Dollinger <emulb...@googlemail.com> wrote: > > 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. >
What does the core team think about a math library with useful (like in the examples above) filters? i.e, {% load math %} ... {{ x|abs }} {{ y|log:"10" }} Most cases I can think of are unary, so they lend nicely to the filter syntax.. In addition to the above, I can think of the following from the python math module: * isinf (and maybe isnan)? to pretty print infinities * trunc. actually this/ceil/floor are somewhat covered by the float formatting functions, but sometimes not enough. I've found use at some project to binary&hexadecimal conversions/bit querying functions (to nicely display bitflags), but that might be overkill for a general purpose library in the core. > 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). Regards, D. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.