BuiltinLibrary class for automatic and easy insertion of custom filters/tags
|Reported by:||Owned by:||nobody|
|Severity:||Keywords:||Builtin Automatic Library|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Re the article here:
(ignoring the digression about email subject lines!)
I put forward the need for a simple way to have filters and tags that I define in my local script automatically available to DJango, without the need for a package import, or a specific 'template' package within my source tree.
I have attached a page of 4 lines (+ documentation) that enables this with the class BuiltinLibrary. Using the class is as follows:
def filter_rst_h1(value, arg='-'): "Write a single underline under the text" line=arg * len(value) return "%s\n%s" % (value, line) from django.template import ``BuiltinLibrary`` # <-- NEW! # set up extra library of routines for later use... library = BuiltinLibrary() library.filter('filter_rst_h1', filter_rst_h1)
The patch and a full, standalone demonstration program is attached.
Thanks for considering this patch...