Ticket #20434: patch3.patch

File patch3.patch, 1.8 KB (added by jonathanslenders, 11 years ago)

The templatetags management command.

  • new file django/core/management/commands/templatetags.py

    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
    - +  
     1from __future__ import unicode_literals
     2
     3from optparse import make_option
     4
     5from django.core.management.base import BaseCommand
     6from django.template.base import get_library, LibraryGrammar
     7from django.template import InvalidTemplateLibrary
     8
     9
     10class 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)
  • django/template/__init__.py

    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,  
    7575# Library management
    7676from django.template.base import (Library, add_to_builtins, builtins,
    7777    get_library, get_templatetags_modules, get_text_list, import_library,
    78     libraries)
     78    libraries, LibraryGrammar)
    7979
    8080# Class based templates
    8181from django.template.generic import Grammar, UnknownGrammar, GrammarException, TemplateTag
Back to Top