Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed lexer_factory() and parser_factory() functions in django.temp…

…late, simplifying the compile_string() logic

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6973 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 36a06edcdff0a0a57f94d94cf9d4574dde147264 1 parent eb95a50
Adrian Holovaty adrianholovaty authored
Showing with 7 additions and 16 deletions.
  1. +7 −16 django/template/__init__.py
23 django/template/__init__.py
View
@@ -175,8 +175,13 @@ def render(self, context):
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 @@ def find_filter(self, filter_name):
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
Please sign in to comment.
Something went wrong with that request. Please try again.