--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
# 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 ""
else:
return val
However I don't know how mature this is to be included in the core. It's also
a matter of taste if you like the syntax or not. But its quite intuitive after
you get the concept.
Maybe this clashes with the 1.3 goal of focusing on bug fixes, but it could be
worth to look at it again for the 1.4 release. In the long run there should
really be a much more easier way to define semi complex tags than with the
current Node approach.
So a +1 from me for every approach making template tags easier.
--
Servus,
Gregor Müllegger
2010/7/22 Alex Robbins <alexander...@gmail.com>:
> 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 me) to be a very common use case. With a helper like
> this, I'd be able to write most of my template tags without needing to
> drop down into the function/node paradigm. Maybe django does
> eventually need to incorporate one of the third party solutions to
> making template tags nice, but this could be a quick win that would
> address a lot of the pain now.
>
> Or maybe most people don't write lots of add_to_context type tags, or
> the current third-party solutions are sufficient. If it isn't a common
> problem for people, then it definitely doesn't belong in the core.
>
> Thanks,
> Alex