-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvement in the patches of the brach 1.4 and 1.5
- Loading branch information
Showing
2 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
diff --git a/django/template/base.py b/django/template/base.py | ||
index e2fc66b..09f114b 100644 | ||
--- a/django/template/base.py | ||
+++ b/django/template/base.py | ||
@@ -220,6 +220,10 @@ class Lexer(object): | ||
else: | ||
token = Token(TOKEN_TEXT, token_string) | ||
token.lineno = self.lineno | ||
+ # token.source is a tuple, this contains origin object and | ||
+ # the range of the columns where is this token. | ||
+ # If TEMPLATE_DEBUG = False we don't need it, therefore we set with (-1, -1) | ||
+ token.source = self.origin, (-1, -1) | ||
self.lineno += token_string.count('\n') | ||
return token | ||
|
||
@@ -297,6 +301,7 @@ class Parser(object): | ||
"in the template." % node) | ||
if isinstance(nodelist, NodeList) and not isinstance(node, TextNode): | ||
nodelist.contains_nontext = True | ||
+ node.source = token.source | ||
nodelist.append(node) | ||
|
||
def enter_command(self, command, token): | ||
diff --git a/django/template/debug.py b/django/template/debug.py | ||
index 74aa82b..8289cc3 100644 | ||
--- a/django/template/debug.py | ||
+++ b/django/template/debug.py | ||
@@ -55,10 +55,6 @@ class DebugParser(Parser): | ||
def create_variable_node(self, contents): | ||
return DebugVariableNode(contents) | ||
|
||
- def extend_nodelist(self, nodelist, node, token): | ||
- node.source = token.source | ||
- super(DebugParser, self).extend_nodelist(nodelist, node, token) | ||
- | ||
def unclosed_block_tag(self, parse_until): | ||
command, source = self.command_stack.pop() | ||
msg = "Unclosed tag '%s'. Looking for one of: %s " % (command, ', '.join(parse_until)) | ||
diff --git a/django/template/loader.py b/django/template/loader.py | ||
index 4185017..82f2ead 100644 | ||
--- a/django/template/loader.py | ||
+++ b/django/template/loader.py | ||
@@ -79,10 +79,9 @@ | ||
return self.loader(self.loadname, self.dirs)[0] | ||
|
||
def make_origin(display_name, loader, name, dirs): | ||
- if settings.TEMPLATE_DEBUG and display_name: | ||
+ if display_name: | ||
return LoaderOrigin(display_name, loader, name, dirs) | ||
- else: | ||
- return None | ||
+ return None | ||
|
||
def find_template_loader(loader): | ||
if isinstance(loader, (tuple, list)): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters