]> Devi Nivas Git - chevron.git/commitdiff
Improve newline handling for standalone's.
authorDaniel Morrison <dan@morrison.ph>
Sun, 16 Nov 2014 05:43:49 +0000 (00:43 -0500)
committerDaniel Morrison <dan@morrison.ph>
Sun, 16 Nov 2014 05:43:49 +0000 (00:43 -0500)
Fixes bug in benchmark. No I’m still not sure I understand.

entei.py

index c53716ff18fd8f376b89a43c83bec740d08ae249..53de592c707459ccb35296a2dbbaebe284abb598 100755 (executable)
--- 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']: