with-html-writer ( quot -- xml ) (original) (raw)

with-html-writer ( quot -- xml )
HTML streams

Prev: ( -- html-writer )

Vocabulary
html.streams

Inputs

quot a quotation

Outputs

xml a xml-chunk

Word description
Calls the quotation in a new dynamic scope with output-stream rebound to an html-writer. When the quotation returns, outputs the accumulated HTML markup.

Examples

USING: io io.styles html.streams xml.writer ; [ "Hello" { { font-style bold } } format nl ] with-html-writer write-xml
Hello

Definition

USING: accessors io kernel ;

IN: html.streams

: with-html-writer ( quot -- xml )
[ swap with-output-stream ] keep data>> ;
inline