On Fri, Jun 26, 2009 at 5:17 AM, Brian May
<br...@microcomaustralia.com.au>wrote:

>
> On Thu, Jun 25, 2009 at 02:03:16PM -0400, Michael wrote:
> > Inclusion tags might help you out with the template idea, but generally
> for
> > variables like this I like to put them in context like this:
> >
> http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#setting-a-variable-in-the-context
>
> Is it possible to do the same thing with register.simple_tag, and maybe
> takes_context (assuming register.simple_tag supports that)?
>
> The example seems to have a lot of overhead, especially if you want to
> parse variables, and most of it is already done by register.simple_tag,
> it seems silly to have to duplicate everything for every tag.
>
> However the documentation seems to suggest it is not possible to
> simplify this?
> --
> Brian May <br...@microcomaustralia.com.au>
>

There has been talks about making the process a little easier. But
once you start setting context, you need to have a node that is
rendered, because it is happening when the template is rendered. It
really isn't that difficult, even if there is a little boiler plate.

That said, I wrote up this easy_template_tag that allows you to set
the functions signature and get directly into the render method of the
node. It saves me some time as I am always breaking apart template
strings. You can check it out here:
http://bitbucket.org/newmaniese/newmanutils/src/tip/newmanutils/decorators/templates.py#cl-31

It's still not perfect, The docstring of the function isn't exposed and I
would rather not have to pass a regex object as the signature, (and a lot of
other things), but works and it saves me a lot of time when writing template
tags.

Hope that helps,

Michael

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to