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
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 ""
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
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
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