Make macros callable from other macros

This commit is contained in:
Marcus Kammer 2023-07-08 17:10:57 +02:00
parent 795d02d8e6
commit 9a21cc255a
Signed by: marcuskammer
GPG key ID: C374817BE285268F
2 changed files with 8 additions and 8 deletions

View file

@ -2,7 +2,7 @@
(in-package :cl-sbt)
(defmacro accordion-header (target title)
(defmacro accordion-header (target name)
`(spinneret:with-html
(:h2 :class "accordion-header"
(:button :class "accordion-button"
@ -11,7 +11,7 @@
:data-bs-target (format nil "#~a" ,target)
:aria-expanded "true"
:aria-controls "collapseOne"
,title))))
,name))))
(defmacro accordion-item (&body body)
`(spinneret:with-html
@ -23,5 +23,5 @@
(:div :class "accordion"
:id ,id
,@(loop for item in rest
collect (destructuring-bind (&key id title) item
`(accordion-item (accordion-header ,id ,title)))))))
collect (destructuring-bind (&key target name) item
`(accordion-item (accordion-header ,target ,name)))))))

View file

@ -11,19 +11,19 @@
(in-package :cl-sbt)
(defmacro nav-item (title active url)
(defmacro nav-item (name active url)
`(spinneret:with-html
(:li :class "nav-item"
(:a :class ,(if active "nav-link active" "nav-link")
:href (format nil "#~a" ,url)
,title))))
,name))))
(defmacro nav ((&key (style nil)) &rest rest)
`(spinneret:with-html
(:ul :class ,(if style (concatenate 'string "nav " style) "nav")
,@(loop for tab in rest
collect (destructuring-bind (&key title active url) tab
`(nav-item ,title ,active ,url))))))
collect (destructuring-bind (&key name active url) tab
`(nav-item ,name ,active ,url))))))
;; ;;
;; ;; For testing purposes