From 0f7f2a48eeaf812d2248b9bff3f8ed215dff139d Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Thu, 23 Jan 2025 15:54:31 +0100 Subject: [PATCH] Simplify with-list-group macro --- src/list-group.lisp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/list-group.lisp b/src/list-group.lisp index 1ab91db..244547c 100644 --- a/src/list-group.lisp +++ b/src/list-group.lisp @@ -66,10 +66,10 @@ ITEMS: A list of items to be included in the list group." (let ((class-str (format nil "list-group~@[ list-group-flush~]" flush))) (spinneret:with-html (:ul :class class-str - (loop for item in items - do (:li :class "list-group-item" item)))))) + (dolist (item items) + (:li :class "list-group-item" item)))))) -(defmacro with-list-group (flush items) +(defmacro with-list-group (flush &rest items) "This macro generates a Bootstrap list group. FLUSH: If true, adds the 'list-group-flush' class. @@ -78,18 +78,15 @@ ITEMS: A list of items to be included in the list group." (let ((class-str (format nil "list-group~@[ list-group-flush~]" flush))) `(spinneret:with-html (:ul :class ,class-str - ,@(if (and (listp items) (eq (car items) 'quote)) - ;; If items is a quoted list, use it directly - (loop :for item :in (cadr items) - :collect `(:li :class "list-group-item" ,item)) - ;; Otherwise, assume it's a variable and generate code to be evaluated at runtime - ;; FUCK YOU COMMON LISP! I really don't understand how this works. :( - ;; If you are able to understand it, and able to explain it to me, please send me an email: - ;; marcus.kammer@mailbox.org - `((dolist (item ,items) - (:li :class "list-group-item" item)))))))) + ,@(loop :for item :in items + :collect `(:li :class "list-group-item" ,item)))))) (defmacro with-list-group* (flush items) + "This macro generates a Bootstrap list group. + +FLUSH: If true, adds the 'list-group-flush' class. + +ITEMS: A list of items to be included in the list group." (let ((class-str (format nil "list-group~@[ list-group-flush~]" flush))) `(spinneret:with-html (:ul :class ,class-str