I'm trying to use the Template library outside of a normal Django
webapp and am having difficulty figuring out the right way to register
a custom filter.
The current implementation works, but I don't like accessing the guts
of the template module (see below), or calling my custom Library a
"builtin".

Whats the right way to do this?  If the answer is "use a different
templating system" then I'm fine with that too... the right tool for
the right job and all that.

Eric
---
#!/bin/env python2.7
import django
import django.template

django.conf.settings.configure()

register = django.template.Library()
@register.filter
def rev(stuff):
    return stuff[::-1]

django.template.builtins.append(register) #Eww.. there has to be a
better way!

tmpl = django.template.Template('{{ "abdc"|rev }}')
print tmpl.render(django.template.Context({}))

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