From 471a60e7752d91da7fd7b2f2bbeee0fe957108a5 Mon Sep 17 00:00:00 2001 From: Daniel Morrison Date: Sun, 16 Nov 2014 00:43:49 -0500 Subject: [PATCH] Improve newline handling for standalone's. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes bug in benchmark. No I’m still not sure I understand. --- entei.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/entei.py b/entei.py index c53716f..53de592 100755 --- a/entei.py +++ b/entei.py @@ -127,8 +127,10 @@ def tokenize(template): if is_standalone and tag_type not in ['variable', 'no escape']: try: until, template = template.split('\n', 1) + newline = True except ValueError: until, template = (template, '') + newline = False # If the stuff to the right of us are spaces if until.isspace() or until == '': @@ -143,9 +145,12 @@ def tokenize(template): else: # TODO: Understand this code. if tag_type == 'set delimiter?': - template = until + template = until + template else: - template = until + '\n' + template + if newline: + template = until + '\n' + template + else: + template = until + template # If we're a tag can't be a standalone elif tag_type in ['variable', 'no escape']: -- 2.47.3