From 36a06edcdff0a0a57f94d94cf9d4574dde147264 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 22 Dec 2007 19:28:21 +0000 Subject: [PATCH] Removed lexer_factory() and parser_factory() functions in django.template, simplifying the compile_string() logic git-svn-id: http://code.djangoproject.com/svn/django/trunk@6973 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/template/__init__.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/django/template/__init__.py b/django/template/__init__.py index 8cf83e40c5a..62a394cdbaa 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -175,8 +175,13 @@ class Template(object): def compile_string(template_string, origin): "Compiles template_string into NodeList ready for rendering" - lexer = lexer_factory(template_string, origin) - parser = parser_factory(lexer.tokenize()) + if settings.TEMPLATE_DEBUG: + from debug import DebugLexer, DebugParser + lexer_class, parser_class = DebugLexer, DebugParser + else: + lexer_class, parser_class = Lexer, Parser + lexer = lexer_class(template_string, origin) + parser = parser_class(lexer.tokenize()) return parser.parse() class Token(object): @@ -334,20 +339,6 @@ class Parser(object): else: raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name) -def lexer_factory(*args, **kwargs): - if settings.TEMPLATE_DEBUG: - from debug import DebugLexer - return DebugLexer(*args, **kwargs) - else: - return Lexer(*args, **kwargs) - -def parser_factory(*args, **kwargs): - if settings.TEMPLATE_DEBUG: - from debug import DebugParser - return DebugParser(*args, **kwargs) - else: - return Parser(*args, **kwargs) - class TokenParser(object): """ Subclass this and implement the top() method to parse a template line. When