From: Daniel Morrison Date: Sun, 16 Nov 2014 05:43:49 +0000 (-0500) Subject: Improve newline handling for standalone's. X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=471a60e7752d91da7fd7b2f2bbeee0fe957108a5;p=chevron.git Improve newline handling for standalone's. Fixes bug in benchmark. No I’m still not sure I understand. --- 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']: