IN: templating USING: kernel xml sequences hashtables tools io arrays namespaces xml-data xml-utils xml-writer test generic ; : sub-tag T{ name f f "sub" "http://littledan.onigirihouse.com/namespaces/replace" } ; SYMBOL: ref-table GENERIC: (r-ref) ( xml -- ) M: tag (r-ref) dup sub-tag tag-attr [ ref-table get hash swap set-tag-children ] [ drop ] if* ; M: object (r-ref) drop ; : template ( xml -- xml ) [ (r-ref) ] xml-each ; ! Example : sample-doc { "" "" "" "
" "

paragraph

" "" } concat ; : test-refs ( -- string ) [ H{ { "foo" { "foo" } } { "bar" { "blah" T{ tag T{ name f "" "a" "" } V{ } f } } } { "baz" f } } ref-table set sample-doc string>xml dup template xml>string ] with-scope ; [ "foo
blah

" ] [ test-refs ] unit-test