Re: New context template tag

2010-07-23 Thread Preston Timmons
I'm a fan of this proposal. I find that most of the tags I build return a variable to the context rather than just rendering a string. And while a few of the tags I have built require more complexity than the decorator approach could handle, the majority of them would be trivial to make if this

Re: New context template tag

2010-07-22 Thread Gregor Müllegger
I'm a huge fan of Alex Gaynor's templatetag sugar syntax for defining template tags: # from the docs: @tag(register, [Constant("for"), Variable(), Optional([Constant("as"), Name()])]): def example_tag(context, val, asvar=None): if asvar: context[asvar] = val return ""

Re: New context template tag

2010-07-22 Thread Alex Robbins
Eric, Thanks for the reply! django-template-utils does help some but, like you say, you still end up writing a function and a custom node. Is there a reason we couldn't add another template tag helper like simple_tag or inclusion_tag? (I'll write the code and tests) Adding to context seems (to

Re: New context template tag

2010-07-22 Thread Eric Holscher
I usually use James Bennett's django-template-utils for this purpose. It has a nice, simple implementation: http://bitbucket.org/ubernostrum/django-template-utils/src/tip/template_utils/nodes.py#cl-11 It still requires the annoying Node/function split though. I know there have been a multitude

New context template tag

2010-07-22 Thread Alex Robbins
I am a huge fan of simple_tag and inclusion_tag. They take a common template tag use case and make it very easy to write. It seems like a common use case that isn't represented is adding a value to context. I find myself writing tags to add a variable to context very often and it seems like we