diff options
Diffstat (limited to 'macros.lisp')
| -rw-r--r-- | macros.lisp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/macros.lisp b/macros.lisp index e9db83d..09b59f4 100644 --- a/macros.lisp +++ b/macros.lisp @@ -6,6 +6,7 @@ (ps ,@body)))) ;; Templating macros +;; TODO needs to be moved to another file (defmacro mu (&rest body) "Macro writing Mustache syntax, namely the '{{ mustache }}'" `(list :raw (concatenate 'string "{{ " ,@body " }}"))) @@ -28,19 +29,21 @@ (defmacro mublock (name attrs &rest body) "Macro writing a block where a '{{ end }}' is followed." - `(list + `(values (mu ,name " " ,attrs) ,@(mapcar (lambda (x) `',x) body) (mu "end"))) -(defmacro muwhen (condition &rest body) - `(mublock "if" ,condition ,@body)) - (defmacro muif (condition do do-else) - `(muwhen ,condition - ,@do - (:RAW `(mu "else")) - ,@do-else)) + `(mublock "if" ,condition + ,@do + ,@(when do-else + (concatenate 'list + (list (mu "else")) + do-else)))) + +(defmacro muwhen (condition &rest do) + `(muif ,condition ,do nil)) (defun quote-if-string (str) (if (stringp str) |
