I've been experimenting with writing some template tags by reading
through the documentation and modifying some existing tags defined by
admin.  I've got something like this:

from django import template
register = template.Library()

def paginator_number(request, i, paginator, page_num):
    #do stuff, eventually returning str output
paginator_number = register.simple_tag(paginator_number)

This works, and I don't understand why.  According to the documentation
(http://www.djangoproject.com/documentation/templates_python/#shortcut-for-simple-tags)
a simple tag is supposed to only take one argument.  Mine, as you see,
takes four.  But it works fine, and somehow the arguments are being
checked, because if I pass in the wrong number I get a
TemplateSyntaxError saying that "paginator_number takes 4 arguments".

So the question I have is are the docs out of date with the actual
capabilities of register.simple_tag()?  It doesn't in fact seem to be
limited to tags that take single arguments.  (For my paginator_number
tag I actually started out with what the admin paginator_number tag
does in admin_list.py...this is where I got the original
register.simple_tag() use.  But it too seems to be registering a tag
that is not simple, since it takes two arguments?)

It's convenient not to have to check the arguments myself but I'm
concerned about running into trouble down the line....

Any enlightenment appreciated,
Karen


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to