2.11.3 Functional Usage
(require web-server/formlets/lib) |
The syntactic shorthand abbreviates the construction of formlets with the following library. These combinators may be used directly to construct low-level formlets, such as those for new INPUT element types. Refer to Predefined Formlets for example low-level formlets using these combinators.
xexpr-forest/c : contract? |
Equivalent to (listof xexpr/c)
(formlet/c content) → contract? |
content : any/c |
Equivalent to (-> integer? (values xexpr-forest/c (-> (listof binding?) (coerce-contract 'formlet/c content)) integer?)).
A formlet’s internal representation is a function from an initial input number to an X-expression forest rendering, a processing function, and the next allowable input number.
(pure value) → (formlet/c any/c) |
value : any/c |
Constructs a formlet that has no rendering and always returns value in the processing stage.
(cross f g) → (formlet/c any/c) |
f : (formlet/c (any/c . -> . any/c)) |
g : (formlet/c any/c) |
Constructs a formlet with a rendering equal to the concatenation of the renderings of formlets f and g; a processing stage that applies g’s processing result to f’s processing result.
(cross* f g ) → (formlet/c any/c) |
f : (formlet/c (() () #:rest (listof any/c) . ->* . any/c)) |
g : (formlet/c any/c) |
Equivalent to cross lifted to many arguments.
(xml-forest r) → (formlet/c procedure?) |
r : xexpr-forest/c |
Constructs a formlet with the rendering r and the identity procedure as the processing step.
(xml r) → (formlet/c procedure?) |
r : xexpr/c |
Equivalent to (xml-forest (list r)).
(text r) → (formlet/c procedure?) |
r : string? |
Equivalent to (xml r).
(tag-xexpr tag attrs inner) → (formlet/c any/c) |
tag : symbol? |
attrs : (listof (list/c symbol? string?)) |
inner : (formlet/c any/c) |
Constructs a formlet with the rendering (list (list* tag attrs inner-rendering)) where inner-rendering is the rendering of inner and the processing stage identical to inner.
(formlet-display f) → xexpr-forest/c |
f : (formlet/c any/c) |
Renders f.
(formlet-process f r) → any/c |
f : (formlet/c any/c) |
r : request? |
Runs the processing stage of f on the bindings in r.