summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2022-08-07 18:25:16 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2022-08-07 18:25:16 -0300
commit20ab54531205d94763f51753c1b02cc42685f4e0 (patch)
treedac26e46161eb1a25d2ba9f4153340e778b00ee9
parentfc731f3a0de136b145340aed864feecc7fb44b8d (diff)
downloadshtml-20ab54531205d94763f51753c1b02cc42685f4e0.tar.gz
shtml-20ab54531205d94763f51753c1b02cc42685f4e0.zip
Add a way to concatenate tags with custom separators
-rw-r--r--package.lisp3
-rw-r--r--shtml.lisp9
2 files changed, 9 insertions, 3 deletions
diff --git a/package.lisp b/package.lisp
index 27fa91f..0da7196 100644
--- a/package.lisp
+++ b/package.lisp
@@ -1,6 +1,7 @@
(uiop:define-package #:shtml
(:use #:cl)
- (:export #:a
+ (:export #:cat
+ #:a
#:abbr
#:address
#:area
diff --git a/shtml.lisp b/shtml.lisp
index 1bb1463..b20ece7 100644
--- a/shtml.lisp
+++ b/shtml.lisp
@@ -1,5 +1,10 @@
(in-package #:shtml)
+(defun cat (separator &rest lines)
+ (format nil
+ (concatenate 'string "~{~a~^" separator "~}")
+ lines))
+
(defun trim-flatten-assoc (lst)
(loop :for (i . j) :in lst
:when j :append (list i j)))
@@ -43,7 +48,7 @@
(mapcar (lambda (attr)
(list 'cons (downcase-name attr) attr))
attrs))))
- `(defmacro ,tag (&rest ,args)
+ `(defmacro ,tag (&body ,args)
(let ((body (gensym))
(parsed-args (separate-keys ,args)))
`((lambda (,body &key ,@',attrs)
@@ -61,7 +66,7 @@
(mapcar (lambda (attr)
(list 'cons (downcase-name attr) attr))
attrs))))
- `(defmacro html (&rest ,args)
+ `(defmacro html (&body ,args)
(let ((body (gensym))
(parsed-args (separate-keys ,args)))
`((lambda (,body &key ,@',attrs)