Slight furnace cleanup

db4
Daniel Ehrenberg 2009-02-08 20:32:11 -06:00
parent 47a751ad6c
commit ea46845ac1
3 changed files with 19 additions and 12 deletions

View File

@ -81,11 +81,18 @@ CHLOE: a
CHLOE: base CHLOE: base
compile-a-url [ [XML <base href=<->/> XML] ] [xml-code] ; compile-a-url [ [XML <base href=<->/> XML] ] [xml-code] ;
: hidden-nested-fields ( -- xml )
nested-forms get " " join f like nested-forms-key
hidden-form-field ;
: render-hidden ( for -- xml )
"," split [ hidden render>xml ] map ;
: compile-hidden-form-fields ( for -- ) : compile-hidden-form-fields ( for -- )
'[ '[
_ [ "," split [ hidden render>xml ] map ] [ f ] if* _ render-hidden
nested-forms get " " join f like nested-forms-key hidden-form-field>xml hidden-nested-fields
[ [ modify-form ] each-responder ] with-string-writer <unescaped> form-modifications
[XML <div style="display: none;"><-><-><-></div> XML] [XML <div style="display: none;"><-><-><-></div> XML]
] [code] ; ] [code] ;

View File

@ -20,8 +20,8 @@ HELP: each-responder
{ $description "Applies the quotation to each responder involved in processing the current request." } ; { $description "Applies the quotation to each responder involved in processing the current request." } ;
HELP: hidden-form-field HELP: hidden-form-field
{ $values { "value" string } { "name" string } } { $values { "value" string } { "name" string } { "xml" "an XML chunk" } }
{ $description "Renders an HTML hidden form field tag." } { $description "Renders an HTML hidden form field tag as XML." }
{ $notes "This word is used by session management, conversation scope and asides." } { $notes "This word is used by session management, conversation scope and asides." }
{ $examples { $examples
{ $example { $example
@ -38,7 +38,7 @@ HELP: link-attr
{ $examples "Conversation scope adds attributes to link tags." } ; { $examples "Conversation scope adds attributes to link tags." } ;
HELP: modify-form HELP: modify-form
{ $values { "responder" "a responder" } } { $values { "responder" "a responder" } { "xml/f" "an XML chunk or f" } }
{ $contract "Emits hidden form fields using " { $link hidden-form-field } "." } { $contract "Emits hidden form fields using " { $link hidden-form-field } "." }
{ $notes "This word is called by " { $link "html.templates.chloe.tags.form" } "." } { $notes "This word is called by " { $link "html.templates.chloe.tags.form" } "." }
{ $examples "Session management, conversation scope and asides use hidden form fields to pass state." } ; { $examples "Session management, conversation scope and asides use hidden form fields to pass state." } ;

View File

@ -77,18 +77,18 @@ GENERIC: link-attr ( tag responder -- )
M: object link-attr 2drop ; M: object link-attr 2drop ;
GENERIC: modify-form ( responder -- ) GENERIC: modify-form ( responder -- xml/f )
M: object modify-form drop ; M: object modify-form f ;
: hidden-form-field>xml ( value name -- xml ) : form-modifications ( -- xml )
[ [ modify-form [ , ] when ] each-responder ] { } make ;
: hidden-form-field ( value name -- xml )
over [ over [
[XML <input type="hidden" value=<-> name=<->/> XML] [XML <input type="hidden" value=<-> name=<->/> XML]
] [ drop ] if ; ] [ drop ] if ;
: hidden-form-field ( value name -- )
hidden-form-field>xml write-xml ;
: nested-forms-key "__n" ; : nested-forms-key "__n" ;
: request-params ( request -- assoc ) : request-params ( request -- assoc )