Created
November 24, 2011 09:49
-
-
Save bertwesarg/1390994 to your computer and use it in GitHub Desktop.
Patch to re-add final newline
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
diff --git i/jinja2/lexer.py w/jinja2/lexer.py | |
index 69865d0..6a540e2 100644 jinja2/lexer.py | |
--- i/jinja2/lexer.py | |
+++ w/jinja2/lexer.py | |
@@ -549,7 +549,12 @@ class Lexer(object): | |
"""This method tokenizes the text and returns the tokens in a | |
generator. Use this method if you just want to tokenize a template. | |
""" | |
+ add_final_nl = False | |
+ if source[-2:] is '\r\n' or source[-1] in ['\r', '\n']: | |
+ add_final_nl = True | |
source = '\n'.join(unicode(source).splitlines()) | |
+ if add_final_nl: | |
+ source += '\n' | |
pos = 0 | |
lineno = 1 | |
stack = ['root'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment