commit 17dcbf4f53e14aaa83b400db8b911e4b68329ed0
Author: Jonathan Slenders <jonathan@slenders.be>
Date: Thu Jun 6 00:23:34 2013 +0200
templatetags management command added.
diff --git a/django/core/management/commands/templatetags.py b/django/core/management/commands/templatetags.py
new file mode 100644
index 0000000..0f929a2
-
|
+
|
|
| 1 | from __future__ import unicode_literals |
| 2 | |
| 3 | from optparse import make_option |
| 4 | |
| 5 | from django.core.management.base import BaseCommand |
| 6 | from django.template.base import get_library, LibraryGrammar |
| 7 | from django.template import InvalidTemplateLibrary |
| 8 | |
| 9 | |
| 10 | class Command(BaseCommand): |
| 11 | help = "Prints the template tags in this application" |
| 12 | args = '<library>' |
| 13 | |
| 14 | def handle(self, library_name=None, **options): |
| 15 | if library_name: |
| 16 | try: |
| 17 | lib = get_library(library_name) |
| 18 | grammar = lib.get_grammar() |
| 19 | print grammar.as_string() |
| 20 | except InvalidTemplateLibrary: |
| 21 | print 'Template tag library not found.' |
| 22 | else: |
| 23 | print LibraryGrammar.from_builtins().as_string(self.style) |
diff --git a/django/template/__init__.py b/django/template/__init__.py
index 0e55d62..c733cc4 100644
a
|
b
|
from django.template.base import (compile_string, resolve_variable,
|
75 | 75 | # Library management |
76 | 76 | from django.template.base import (Library, add_to_builtins, builtins, |
77 | 77 | get_library, get_templatetags_modules, get_text_list, import_library, |
78 | | libraries) |
| 78 | libraries, LibraryGrammar) |
79 | 79 | |
80 | 80 | # Class based templates |
81 | 81 | from django.template.generic import Grammar, UnknownGrammar, GrammarException, TemplateTag |