Skip to content

Commit

Permalink
Improvement in the patches of the brach 1.4 and 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
goinnn committed Oct 1, 2013
1 parent 33883e0 commit e134144
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
55 changes: 55 additions & 0 deletions patches/patch1.4.diff
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)):
9 changes: 6 additions & 3 deletions patches/patch1.5.diff
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ diff --git a/django/template/loader.py b/django/template/loader.py
index cfffb40..244abf3 100644
--- a/django/template/loader.py
+++ b/django/template/loader.py
@@ -80,7 +80,7 @@ class LoaderOrigin(Origin):
@@ -80,10 +80,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
- else:
- return None
+ return None

def find_template_loader(loader):
if isinstance(loader, (tuple, list)):

0 comments on commit e134144

Please sign in to comment.