On 22/12/24 21:38, Maxime Devos wrote:
>
> Unquote-splicing (,@) is your friend:
>
> `(foo ,@(if p? '(a (b) c) '()) d)
>
> When p? -> (foo a (b) c d).
>
> When (not p?) -> (foo d).
>
> Now do this for SXML …
>
Ah, splicing... yes Maxime, that works :)
So I applied it as follows:
(define* (special-input #:key name (required? #true))
"Return an SXHTML INPUT element for typing text."
`(input
(@ (type "text")
(name ,name)
,@(if required? '((required "")) '()))))
And now converting to XML I get the results I expected:
(sxml->xml (special-input #:name "author"))
→
(sxml->xml (special-input #:name "author" #:required? #false))
→
Thank you very much,