mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	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:
		| @@ -175,8 +175,13 @@ class Template(object): | |||||||
|  |  | ||||||
| def compile_string(template_string, origin): | def compile_string(template_string, origin): | ||||||
|     "Compiles template_string into NodeList ready for rendering" |     "Compiles template_string into NodeList ready for rendering" | ||||||
|     lexer = lexer_factory(template_string, origin) |     if settings.TEMPLATE_DEBUG: | ||||||
|     parser = parser_factory(lexer.tokenize()) |         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() |     return parser.parse() | ||||||
|  |  | ||||||
| class Token(object): | class Token(object): | ||||||
| @@ -334,20 +339,6 @@ class Parser(object): | |||||||
|         else: |         else: | ||||||
|             raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name) |             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): | class TokenParser(object): | ||||||
|     """ |     """ | ||||||
|     Subclass this and implement the top() method to parse a template line. When |     Subclass this and implement the top() method to parse a template line. When | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user