commit 1bf7397ac869edaeb1032904aca8f6f66cdc2791
parent e803175aff6ba01c16b63dd9c181d76c89646dd8
Author: Eli Barzilay <eli@barzilay.org>
Date: Fri, 2 Jul 2010 01:13:39 -0400
Added `split-attributes+body', to make it easy to write xml-like wrapper
functions, and used it in `center-div'.
original commit: e339081fd037d8ac7ba0128414af182314cef8f0
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/collects/meta/web/html/xml.rkt b/collects/meta/web/html/xml.rkt
@@ -37,6 +37,15 @@
"missing attribute value for `~s:'" a)]
[else (loop (cddr xs) (cons (cons a (cadr xs)) as))]))))
+;; similar, but keeps the attributes as a list, useful to build new functions
+;; that accept attributes without knowing about the xml structs.
+(provide split-attributes+body)
+(define (split-attributes+body xs)
+ (let loop ([xs xs] [as '()])
+ (if (and (pair? xs) (pair? (cdr xs)) (attribute->symbol (car xs)))
+ (loop (cddr xs) (list* (cadr xs) (car xs) as))
+ (values (reverse as) xs))))
+
;; ----------------------------------------------------------------------------
;; An output that handles xml quoting, customizable