Simplify with-list-group macro
This commit is contained in:
parent
34a6e478e2
commit
0f7f2a48ee
1 changed files with 10 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue