Finishing getting rid of html.elements from basis

db4
Daniel Ehrenberg 2009-02-06 10:54:13 -06:00
parent 3ec78f3766
commit b206c5a2d1
9 changed files with 43 additions and 42 deletions

View File

@ -10,7 +10,6 @@ xml.writer
xml.traversal
xml.syntax
html.components
html.elements
html.forms
html.templates
html.templates.chloe
@ -58,14 +57,6 @@ CHLOE: write-atom drop [ write-atom-feeds ] [code] ;
#! Side-effects current namespace.
'[ [ [ _ ] dip link-attr ] each-responder ] [code] ;
: a-start-tag ( tag -- )
[ <a ] [code]
[ attrs>> non-chloe-attrs-only compile-attrs ]
[ compile-link-attrs ]
[ compile-a-url ]
tri
[ =href a> ] [code] ;
: process-attrs ( assoc -- newassoc )
[ "@" ?head [ value present ] when ] assoc-map ;
@ -76,54 +67,61 @@ CHLOE: write-atom drop [ write-atom-feeds ] [code] ;
[ non-chloe-attrs ]
[ compile-link-attrs ]
[ compile-a-url ] tri
[ swap "href" swap set-at ] [code] ;
[ present swap "href" swap [ set-at ] keep ] [code] ;
CHLOE: a
[
[ a-attrs ]
[ compile-children>string ] bi
[ <unescaped> [XML <a><-></a> XML] swap >>attrs ]
[xml-code] ;
[ <unescaped> [XML <a><-></a> XML] second swap >>attrs ]
[xml-code]
] compile-with-scope ;
CHLOE: base
compile-a-url [ [XML <base href=<->/> XML] ] [xml-code] ;
USE: io.streams.string
: compile-hidden-form-fields ( for -- )
'[
<div "display: none;" =style div>
[
_ [ "," split [ hidden render ] each ] when*
nested-forms get " " join f like nested-forms-key hidden-form-field
[ modify-form ] each-responder
</div>
] with-string-writer <unescaped>
[XML <div style="display:none;"><-></div> XML]
] [code] ;
: compile-form-attrs ( method action attrs -- )
[ <form ] [code]
[ compile-attr [ =method ] [code] ]
[ compile-attr [ resolve-base-path =action ] [code] ]
[ compile-attrs ]
tri*
[ form> ] [code] ;
: (compile-form-attrs) ( method action -- )
! Leaves an assoc on the stack at runtime
[ compile-attr [ "method" pick set-at ] [code] ]
[ compile-attr [ resolve-base-path "action" pick set-at ] [code] ]
bi* ;
: form-start-tag ( tag -- )
[
: compile-method/action ( tag -- )
! generated code is ( assoc -- assoc )
[ "method" optional-attr "post" or ]
[ "action" required-attr ]
[ attrs>> non-chloe-attrs-only ] tri
compile-form-attrs
]
[ "for" optional-attr compile-hidden-form-fields ] bi ;
[ "action" required-attr ] bi
(compile-form-attrs) ;
: form-end-tag ( tag -- )
drop [ </form> ] [code] ;
: compile-form-attrs ( tag -- )
[ non-chloe-attrs ]
[ compile-link-attrs ]
[ compile-method/action ] tri ;
: hidden-fields ( tag -- )
"for" optional-attr compile-hidden-form-fields ;
CHLOE: form
[
{
[ compile-link-attrs ]
[ form-start-tag ]
[ compile-children ]
[ form-end-tag ]
} cleave
[ compile-form-attrs ]
[ hidden-fields ]
[ compile-children>string ] tri
[
<unescaped> [XML <form><-><-></form> XML] second
swap >>attrs
write-xml
] [code]
] compile-with-scope ;
: button-tag-markup ( -- xml )

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces make assocs sequences kernel classes splitting
words vocabs.loader accessors strings combinators arrays
continuations present fry urls http http.server xml.literals xml.writer
continuations present fry urls http http.server xml.syntax xml.writer
http.server.redirection http.server.remapping ;
IN: furnace.utilities

View File

@ -11,7 +11,7 @@ IN: html.components
GENERIC: render* ( value name renderer -- xml )
: render ( name renderer -- )
: render>xml ( name renderer -- xml )
prepare-value
[
dup validation-error?
@ -20,7 +20,10 @@ GENERIC: render* ( value name renderer -- xml )
if
] 2dip
render*
swap 2array write-xml ;
swap 2array ;
: render ( name renderer -- )
render>xml write-xml ;
SINGLETON: label