| 915 | class BuiltinLibrary(Library): |
| 916 | """ |
| 917 | Same as Library class but automatically registers filters/tags with DJango. |
| 918 | |
| 919 | Example filter:: |
| 920 | |
| 921 | def filter_rst_h1(value, arg='-'): |
| 922 | "Write a single underline under the text" |
| 923 | line=arg * len(value) |
| 924 | return "%s\n%s" % (value, line) |
| 925 | |
| 926 | To use this filter, do this:: |
| 927 | |
| 928 | from django.template import BuiltinLibrary # <-- NEW! |
| 929 | |
| 930 | # set up extra library of routines for later use... |
| 931 | library = BuiltinLibrary() |
| 932 | library.filter('filter_rst_h1', filter_rst_h1) |
| 933 | """ |
| 934 | def __init__(self, *args, **kwargs): |
| 935 | Library.__init__(self, *args, **kwargs) |
| 936 | builtins.append(self) |
| 937 | |