mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
eb95a50cd6
commit
36a06edcdf
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue