On Mon, May 2, 2011 at 11:46 PM, Phui Hock <phuih...@gmail.com> wrote:
> On May 3, 7:43 am, Russell Keith-Magee <russ...@keith-magee.com> > wrote: > > This stems back to the design motivation of Django's template language > > -- you shouldn't be doing math in the template. Instead, you should be > > doing your math in the view, and providing the template with a > > pre-calculated result. > > > > So, my inclination would be to say no, this doesn't have a place in > > the default list of tags. > > > > Yours, > > Russ Magee %-) > > The example I provided is a bad one, but the math tag is general > purpose. It can potentially reduce the number of custom filters or > amount of work needed in the view function. > > Here's another take: > {% load mathtag %} > {% with x=request.GET.x y=request.GET.y z=request.GET.z %} > if x = {{ x }}, y = {{ y }}, {{ x }} + {{ y }} = {% math x y "$1 * > $2" as result %}{{ result }}<br/> > if x = {{ x }}, y = {{ y }}, {{ x }} * {{ y }} = {% math x y "$1 * > $2" as result %}{{ result }}<br/> > if x = {{ x }}, y = {{ y }}, z = {{ z }}, ({{ x }}^{{ z }}) * > ({{ y }}^{{ z }}) = {% math x y z "($1**$3) * ($2**$3)" as result %} > {{ result }}<br/> > if x = {{ x }}, y = {{ y }}, z = {{ z }}, ({{ x }} + {{ y }}) / > {{ z }} = {% math x y z "($1 + $2) / $3" as result %}{{ result }}<br/> > {% endwith %} > > > Given the frequency of such request by other users warrants a re-look > IMO. > > -- > 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. > > Holy god, not to be rude, but given that this is completely unreadable I'm even more -1 than I ever would have been on the basis of the principle of a dumber template language. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero -- 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.