unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* SXML and optional attributes
@ 2024-12-22 21:23 Luis Felipe
  2024-12-22 21:38 ` Maxime Devos via General Guile related discussions
  0 siblings, 1 reply; 3+ messages in thread
From: Luis Felipe @ 2024-12-22 21:23 UTC (permalink / raw)
  To: Guile User


[-- Attachment #1.1.1: Type: text/plain, Size: 1126 bytes --]

Hi,

I'd like to add attributes to SXML elements conditionally, but I don't 
see how.

I'm looking for a hypothetical "if*" that allows me to do the following:

(define* (special-input #:key name (required? #true))
   "Return an SXHTML INPUT element for typing text."
   `(input
     (@ (type "text")
        (name ,name)
        ,(if* required? '(required "")))))

The built-in "if" doesn't work here because it will return 
#<unspecified> when the condition is false, which is not an acceptable 
attribute. I'm not aware of any value that can be returned in an "else" 
expression that would mean "nothing" to SXML; the empty list is not it:

   ,(if required? '(required "") '())

I'm hoping to find something better than the following workaround:

(define* (special-input #:key name (required? #true))
   "Return an SXHTML INPUT element for typing text."
   (if required?
       `(input (@ (type "text") (name ,name) (required "")))
       `(input (@ (type "text") (name ,name)))))

Any ideas?

-- 
Luis Felipe López Acevedo
https://luis-felipe.gitlab.io/


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 2881 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-23  0:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-22 21:23 SXML and optional attributes Luis Felipe
2024-12-22 21:38 ` Maxime Devos via General Guile related discussions
2024-12-23  0:01   ` Luis Felipe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).