aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-02 13:48:18 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-02 13:48:18 +0100
commit277405e703dde048306c55ab564de0e1e7f78c16 (patch)
treee3d7b4923797ce62ecc0082ca78ea6e2186931a1
parent3658bd65caa8f4bfcfc38bd51353dfe43adcea42 (diff)
Skip single newlines after directives.
-rw-r--r--json-template.lisp13
1 files changed, 11 insertions, 2 deletions
diff --git a/json-template.lisp b/json-template.lisp
index 59e1265..237d627 100644
--- a/json-template.lisp
+++ b/json-template.lisp
@@ -31,6 +31,7 @@
(defun tokenize-template-string (string)
(loop with in-command-p = nil
+ with skip-newline-p = nil
with position = 0
for terminator = (position (if in-command-p #\} #\{) string
:start position)
@@ -38,8 +39,16 @@
(subseq string
position
(or terminator (length string))))
- do (setq position (and terminator (1+ terminator))
- in-command-p (not in-command-p))
+ do (setq position (and terminator (1+ terminator)))
+ when (and skip-newline-p
+ position
+ (< position (length string))
+ (char= (char string position) #\Newline))
+ do (incf position)
+ do (setq in-command-p (not in-command-p)
+ skip-newline-p (and in-command-p
+ position
+ (char= (char string position) #\.)))
until (null terminator)))
(defun parse-template-string (stream)