Use local var for class string

This commit is contained in:
Marcus Kammer 2023-09-01 15:25:51 +02:00
parent 1867223593
commit 932bbdb9d7

View file

@ -32,17 +32,18 @@
(defmacro badge ((&key (color "primary") (pill nil)) &body body) (defmacro badge ((&key (color "primary") (pill nil)) &body body)
"This macro generates a Bootstrap badge. "This macro generates a Bootstrap badge.
COLOR: (optional) The type of the badge (like 'primary', 'secondary', 'success', etc.). Defaults to 'primary'. COLOR: The type of the badge (like 'primary', 'secondary', 'success', etc.). Defaults to 'primary'.
BODY: The contents of the badge. BODY: The contents of the badge.
Example: Example:
(badge (:color \"success\" :pill t) \"New\")" (badge (:color \"success\" :pill t) \"New\")"
`(spinneret:with-html (let ((class-str (concatenate 'string
(:span :class ,(concatenate 'string (format nil "badge text-bg-~a" color)
(format nil "badge text-bg-~a" color) (if (null pill) "" " rounded-pill"))))
(if (null pill) "" " rounded-pill")) `(spinneret:with-html
,@body))) (:span :class ,class-str
,@body))))
(defmacro define-badge (color &optional (pill nil)) (defmacro define-badge (color &optional (pill nil))
"This macro defines a new macro for creating a Bootstrap badge of a specific type. "This macro defines a new macro for creating a Bootstrap badge of a specific type.