- html-page contents #!key css title (doctype ) (headers ) charset content-type literal-style? html-attribs body-attribsprocedure
Generates an HTML page containing contents (a string). If contents starts with "<body" (case insensitive), html-page won't use the <body> tag to enclose contents. The following keywords arguments may be used to customize the page:
- headers: a string (when not in SXML mode) or an SXML form (when in SXML mode) containing additional headers to be inserted in the section delimited by the <head> tag. Default = "".
- title: the title for the page (to be used in the <title> tag). Default = "".
- css: may be either a path to a Cascading Style Sheet file, to be linked from the generated page (the default value is #f, so no CSS is used) or a list of paths to CSS files. If a list of paths is used, the elements which are also lists are read and inlined into the generated page. Example: css: '("css1.css" ("css2.css")). In the example, css1.css would be linked from the generated page (using the link tag) and css2.css would be inlined into the generated page (e.g., html-page would read the css2.css file and inline its contents in the HTML code).
- doctype: specifies the document type of the generated page. The default value is doctype:html-4.01-strict. The possible values are the ones available from the doctype egg.
- charset: specifies the default charset to be used in the corresponding meta tag of the document. The default value is "UTF-8" (only when content-type is provided).
- literal-style? (introduced in version 0.9): if #f, convert special characters in style code (CSS) to theyr equivalent HTML entities. If non-#f, insert them verbatim.
- content-type (introduced in version 0.9) and charset work together: if content-type is provided and charset is not provided, charset is assumed to be "UTF-8"; if charset is provided and content-type is not provided, content-type is assumed to be "text/html" (if html-tags' generate-sxml? is #f) or "application/xhtml+xml" (if generate-sxml? is non-#f).
- html-attribs (introduced in version 0.10): attributes to the html tag. The format is a list of lists (<attribute> <value>) (<attribute> is a symbol). Example: (html-page "foo" html-attribs: '((lang "us"))).
- body-attribs (introduced in version 0.10): attributes to the body tag. The format is a list of lists (<attribute> <value>) (<attribute> is a symbol). Example: (html-page "foo" body-attribs: '((bgcolor "red"))).
Examples:
(html-page "hello")
Produces:
"<html><head></head><body>hello</body></html>"
(html-page "hello" title: "hello")
Produces:
"<html><head><title>hello</title></head><body>hello</body></html>"
(use doctype) (html-page "hello" title: "hello" doctype: xhtml-1.0-strict)
Produces:
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><title>hello</title></head><body>hello</body></html>"
(html-page "hello" headers: (<script> type: "text/javascript" src: "my-script.js"))
Produces:
"<html><head><script type='text/javascript' src='my-script.js'></script></head><body>hello</body></html>"
(use html-tags html-utils) (parameterize ((generate-sxml? #t)) (html-page "hello" headers: (<script> type: "text/javascript" src: "my-script.js")))
Produces:
(html (head (script (@ (type "text/javascript") (src "my-script.js")))) (body "hello"))