]> Devi Nivas Git - chevron.git/commitdiff
Added support for delimiters to be any size
authornoah morrison <noah@morrison.ph>
Thu, 6 Nov 2014 22:25:05 +0000 (17:25 -0500)
committernoah morrison <noah@morrison.ph>
Thu, 6 Nov 2014 22:25:05 +0000 (17:25 -0500)
Instead of needing them to be 2 characters.

Also ignores all spaces in the center (instead of expecting one).

And fixed a bug where delimiters would eat some trailing characters!

entei.py

index fb8c7137fd934fd4386e92ed8f7859772dc71100..485ebad5f719b52197a28ddea9a0f0ed62892af2 100755 (executable)
--- a/entei.py
+++ b/entei.py
@@ -45,8 +45,8 @@ def tokenize(template):
         until = until or l_del
         literal = get()
         while not template.closed:
-            if literal[-2:] == until:
-                return literal[:-2]
+            if literal[-len(until):] == until:
+                return literal[:-len(until)]
 
             literal += get()
 
@@ -96,8 +96,8 @@ def tokenize(template):
 
         elif tag_type == 'set delimiter?':
             if tag_key[-1] == '=':
-                l_del, r_del = tag_key[:-1].split(' ')
-                get(2)
+                dels = tag_key[:-1].strip().split(' ')
+                l_del, r_del = dels[0], dels[-1]
                 continue
 
         elif tag_type in ['section', 'inverted section']: