Tick #2539 "Custom tags and filters can be restricted by namespace"
was one of the ones I was going to pick up during the django sprint,
but someone else beat me to it.  However, the other day I noticed that
the patch against it was old, and admitted to be incomplete by its
author.  Since namespacing of tags and libraries is such a honking
great idea :) -- and something I've wanted for quite some time, I
decided to put a complete patch together for it.

The patch adds a few tests and docs; the idea has already been
approved by Adrian, so it just needs a review from someone not me to
say if it's ready for checkin or not.


The patch is described in detail on the ticket, but here's an extract:


All tag libraries have an associated fully qualified name, which looks
like "app_name.tag_library_name"; this fully qualified name can be
used instead of the unqualified library_name in the {% load %} tag:

Normally we'd do

{% load humanize %}

But if another installed app has a 'humanize' tag libary, we might need to do

{% load django.contrib.humanize.humanize %}

If more than one installed app has a tag library with the same name,
then the app closest to the start of the INSTALLED_APPS list will take
precedence if the unqualified name is used.

Correspondingly, templatetags and filters are also namespaced -- by
the name of the tag library as given to {% load %}. So you can do
this:

{% load library %}
{% load otherapp.library %}

{% library.mytag %} # Outputs "A"
{% otherapp.library.mytag %} # Outputs "B"

But not this:

{% load firstapp.library %}
{% library.mytag %} # We've not loaded anything as 'library'


Cheers,

A.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to