From 03eeb86a5f0fce67fe46acc8e7aff6d2c408d280 Mon Sep 17 00:00:00 2001 From: interp Date: Wed, 2 Oct 2002 12:02:56 +0000 Subject: [PATCH] factor out transformers --- scheme/httpd/surflets/surflets.scm | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scheme/httpd/surflets/surflets.scm b/scheme/httpd/surflets/surflets.scm index d094611..d732e8f 100644 --- a/scheme/httpd/surflets/surflets.scm +++ b/scheme/httpd/surflets/surflets.scm @@ -313,15 +313,19 @@ ,(and attributes (cdr attributes)) )))))) -(define (make-number-input-field . maybe-further-attributes) +(define make-number-input-field + (let ((number-input-field-transformer + (lambda (string) + (or (string->number string) + (error "wrong type"))) + )) + (lambda maybe-further-attributes) (let ((name (generate-input-field-name "number"))) (optionals maybe-further-attributes ((attributes XML-attribute?)) (make-input-field name - (lambda (string) - (or (string->number string) - (error "wrong type"))) + number-input-field-transformer `(input (@ (type "text") (name ,name) ,(and attributes (cdr attributes)))))))) @@ -357,14 +361,13 @@ ;; preselected option: (selected) ;; changed return value: (value new-value) ;; returns a select input field with several options -(define (make-select-input-fields options . maybe-further-attributes) +(define (make-select-input-field options . maybe-further-attributes) (let ((name (generate-input-field-name "select"))) (optionals maybe-further-attributes ((attributes XML-attribute?)) (make-input-field name - (lambda (select) - select) ;FIXME[extension] refer to list elements + identity ;FIXME[extension] refer to list elements `(select (@ ((name ,name) ,(and attributes (cdr attributes)))) #\newline @@ -440,17 +443,19 @@ ,(and button-caption `(value ,button-caption)) ,(and attributes (cdr attributes))))) +(define (string-or-symbol? a) + (or (string? a) + (symbol? a))) + (define (make-submit-button . maybe-further-attributes) (optionals maybe-further-attributes - ((button-caption (lambda (a) (or (string? a) - (symbol? a)))) + ((button-caption string-or-symbol?) (attributes XML-attribute?)) (make-button "submit" button-caption attributes))) (define (make-reset-button . maybe-further-attributes) (optionals maybe-further-attributes - ((button-caption (lambda (a) (or (string? a) - (symbol? a)))) + ((button-caption string-or-symbol?) (attributes XML-attribute?)) (make-button "reset" button-caption attributes)))