((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/html-utils" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "html-utils" (toc) (section 3 "Introduction" (p (tt "html-utils") " is an extension which provides procedures to ease the generation of some frequently used [SX]HTML structures.") (p (tt "html-utils") " is based on " (int-link "/egg/html-tags" "html-tags") ", so it can generate strings or SXML code.  The html-tags' " (tt "generate-sxml?") " parameter (yields a boolean) specifies whether html-utils should generate strings or SXML code.") (p "Example:") (pre " $ csi -n\n #;1> (use html-tags html-utils)\n #;2> (generate-sxml?)\n #f\n #;3> (itemize '(1 2 3))\n \"<ul><li>1</li><li>2</li><li>3</li></ul>\"\n #;4> (generate-sxml? #t)\n #t\n #;5> (itemize '(1 2 3))\n (ul (li 1) (li 2) (li 3))")) (section 3 "Author" (p (int-link "/users/mario-domenech-goulart" "Mario Domenech Goulart"))) (section 3 "Procedures" (section 4 (tt "itemize") (def (sig (procedure "(itemize items #!key list-id list-class quote-procedure)" (id itemize))) (p "Generates an HTML unordered list of " (tt "items") ".  The following attributes may be used:") (ul (li (tt "list-id") ": the value for the HTML " (tt "id") " attribute for the list.") (li (tt "list-class") ": the value for the HTML " (tt "class") " attribute for the list.") (li (tt "quote-procedure") ": an one-argument procedure to specify the quoting of attributes' values for tags.")) (p "Examples:") (highlight scheme "(itemize '(apple watermelon strawberry))") (p "Produces:") (pre " \"<ul><li>apple</li><li>watermelon</li><li>strawberry</li></ul>\"") (highlight scheme "(itemize '(apple watermelon strawberry) list-id: \"my-list\" list-class: \"lists\")") (p "Produces:") (pre " \"<ul id='my-list' class='lists'><li>apple</li><li>watermelon</li><li>strawberry</li></ul>\""))) (section 4 (tt "enumerate") (def (sig (procedure "(enumerate items #!key list-id list-class quote-procedure)" (id enumerate))) (p "Generates an HTML ordered list of " (tt "items") ".  See " (tt "itemize") "."))) (section 4 (tt "html-page") (def (sig (procedure "(html-page contents #!key css title (doctype \"\") (headers \"\") charset content-type literal-style? html-attribs body-attribs)" (id html-page))) (p "Generates an HTML page containing " (tt "contents") " (a string). If contents starts with " (tt "\"<body\"") " (case insensitive), " (tt "html-page") " won't use the " (tt "<body>") " tag to enclose " (tt "contents") ". The following keywords arguments may be used to customize the page:") (ul (li (tt "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 " (tt "<head>") " tag. Default = " (tt "\"\"") ".") (li (tt "title") ": the title for the page (to be used in the " (tt "<title>") " tag). Default = " (tt "\"\"") ".") (li (tt "css") ": may be either a path to a Cascading Style Sheet file, to be linked from the generated page (the default value is " (tt "#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: " (tt "css: '(\"css1.css\" (\"css2.css\"))") ". In the example, " (tt "css1.css") " would be linked from the generated page (using the link tag) and " (tt "css2.css") " would be inlined into the generated page (e.g., " (tt "html-page") " would read the " (tt "css2.css") " file and inline its contents in the HTML code).") (li (tt "doctype") ": specifies the document type of the generated page. The default value is " (tt "doctype:html-4.01-strict") ". The possible values are the ones available from the " (int-link "doctype") " egg.") (li (tt "charset") ": specifies the default charset to be used in the corresponding meta tag of the document. The default value is " (tt "\"UTF-8\"") " (only when " (tt "content-type") " is provided).") (li (tt "literal-style?") " (introduced in version 0.9): if " (tt "#f") ", convert special characters in style code (CSS) to theyr equivalent HTML entities.  If non-" (tt "#f") ", insert them verbatim.") (li (tt "content-type") " (introduced in version 0.9) and " (tt "charset") " work together: if " (tt "content-type") " is provided and " (tt "charset") " is not provided, " (tt "charset") " is assumed to be " (tt "\"UTF-8\"") "; if " (tt "charset") " is provided and " (tt "content-type") " is not provided, " (tt "content-type") " is assumed to be " (tt "\"text/html\"") " (if " (int-link "/egg/html-tags" "html-tags") "' " (tt "generate-sxml?") " is " (tt "#f") ") or " (tt "\"application/xhtml+xml\"") " (if " (tt "generate-sxml?") " is non-" (tt "#f") ").") (li (tt "html-attribs") " (introduced in version 0.10): attributes to the " (tt "html") " tag. The format is a list of lists " (tt "(<attribute> <value>)") " (" (tt "<attribute>") " is a symbol).  Example: " (tt "(html-page \"foo\" html-attribs: '((lang \"us\")))") ".") (li (tt "body-attribs") " (introduced in version 0.10): attributes to the " (tt "body") " tag. The format is a list of lists " (tt "(<attribute> <value>)") " (" (tt "<attribute>") " is a symbol).  Example: " (tt "(html-page \"foo\" body-attribs: '((bgcolor \"red\")))") ".")) (p "Examples:") (highlight scheme "(html-page \"hello\")") (p "Produces:") (pre " \"<html><head></head><body>hello</body></html>\"") (highlight scheme "(html-page \"hello\" title: \"hello\")") (p "Produces:") (pre " \"<html><head><title>hello</title></head><body>hello</body></html>\"") (highlight scheme "(use doctype)\n(html-page \"hello\" title: \"hello\" doctype: xhtml-1.0-strict)") (p "Produces:") (pre " \"<!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>\"") (highlight scheme "(html-page \"hello\" headers: (<script> type: \"text/javascript\" src: \"my-script.js\"))") (p "Produces:") (pre " \"<html><head><script type='text/javascript' src='my-script.js'></script></head><body>hello</body></html>\"    ") (highlight scheme "(use html-tags html-utils)\n(parameterize ((generate-sxml? #t))\n  (html-page \"hello\"\n             headers: (<script> type: \"text/javascript\"\n                                src: \"my-script.js\")))") (p "Produces:") (pre " (html (head (script (@ (type \"text/javascript\") (src \"my-script.js\")))) (body \"hello\"))"))) (section 4 (tt "combo-box") (def (sig (procedure "(combo-box name options #!key default id first-empty onchange onkeyup disabled length multiple selectedindex size tabindex type class)" (id combo-box))) (p "Generates an HTML combo box using " (tt "<select>") " and " (tt "<option>") " tags. The keyword parameters " (tt "id") ", " (tt "onchange") ", " (tt "onkeyup") ", " (tt "disabled") ", " (tt "length") ", " (tt "multiple") ", " (tt "selectedindex") ", " (tt "size") ", " (tt "tabindex") ", " (tt "type") " and " (tt "class") " are passed to the " (tt "<select>") " procedure (from " (int-link "/egg/html-tags" "html-tags") "). " (tt "default") " is the value from the list of options to be selected.  If " (tt "first-empty") " is " (tt "#t") ", the first option of the combo box will be empty.") (p "Example:") (highlight scheme "(combo-box \"test\" '(#(1 1) #(2 2) #(3 3)) first-empty: #t default: 2)") (p "Produces:") (pre "\"<select name='test' id='test'><option></option><option value='1'>1</option><option value='2' selected>2</option><option value='3'>3</option></select>\""))) (section 4 (tt "hidden-input") (def (sig (procedure "(hidden-input name/list #!optional value id)" (id hidden-input))) (p "Generates an HTML hidden input field. " (tt "name/list") " can be either a string representing the name attribute of the HTML input tag or an alist mapping names to values to be used by the corresponding input tags.  When " (tt "name/list") " is a string, so representing the name of the input tag, the optional values VALUE and ID can be used to be represent the values of their corresponding HTML attributes.") (p "Examples:") (highlight scheme "(hidden-input 'secret-var \"secret-val\")") (p "Produces:") (pre " \"<input type='hidden' name='secret-var' id='secret-var' value='secret-val'>\"") (highlight scheme "(hidden-input '((secret-var1 . \"secret-val1\") (secret-var2 . \"secret-val2\")))") (p "Produces:") (pre " \"<input type='hidden' id='secret-var1' name='secret-var1' value='secret-val1'><input type='hidden' id='secret-var2' name='secret-var2' value='secret-val2'>\""))) (section 4 (tt "text-input") (def (sig (procedure "(text-input name . args)" (id text-input))) (p "Generates an input text box. " (tt "args") " are keyword arguments to be passed to " (tt "<input>") " (from " (int-link "/egg/html-tags" "html-tags") ").") (p "Examples:") (highlight scheme "(text-input \"foo\" value: \"bar\")") (p "Produces:") (pre " \"<input type='text' name='foo' id='foo' value='bar'>\""))) (section 4 (tt "password-input") (def (sig (procedure "(password-input name . args)" (id password-input))) (p "The same as " (tt "text-input") ", but for password inputs."))) (section 4 (tt "submit-input") (def (sig (procedure "(submit-input . args)" (id submit-input))) (p "Generates a submit widget.  " (tt "args") " are keyword arguments to be passed to " (tt "<input>") " (from " (int-link "/egg/html-tags" "html-tags") ").") (highlight scheme " (submit-input value: \"Send!\")") (p "Produces:") (pre " \"<input type='submit' value='Send!'>\""))) (section 4 (tt "tabularize") (def (sig (procedure "(tabularize items #!key table-id table-class quote-procedure even-row-class odd-row-class header)" (id tabularize))) (p "Generates an HTML table from " (tt "items") " (a list of lists). The following keyword parameters may be used:") (ul (li (tt "table-id") ": the value for the HTML " (tt "id") " attribute for the table.") (li (tt "table-class") ": the value for the HTML " (tt "class") " attribute for the table.") (li (tt "quote-procedure") ": an one-argument procedure to specify the quoting of attributes' values for tags.") (li (tt "even-row-class") ": the value for the HTML " (tt "class") " attribute for even rows of the the table.") (li (tt "odd-row-class") ": the value for the HTML " (tt "class") " attribute for odd rows of the the table.") (li (tt "header") ": a list of column names to be used as the table header (enclosed by the " (tt "th") " tag).") (li (tt "thead/tbody") ": if " (tt "#t") ", generates the table with " (tt "<thead>") " and " (tt "<tbody>") " tags.")) (p "Examples:") (highlight scheme "(tabularize '((1 2 3) (4 5 6)))") (p "Produces:") ((pre "\n\"" "<" "table" ">" "<" "tr" ">" "<" "td" ">" "1" "<" "/td" ">" "<" "td" ">" "2" "<" "/td" ">" "<" "td" ">" "3" "<" "/td" ">" "<" "/tr" ">" "<" "tr" ">" "<" "td" ">" "4" "<" "/td" ">" "<" "td" ">" "5" "<" "/td" ">" "<" "td" ">" "6" "<" "/td" ">" "<" "/tr" ">" "<" "/table" ">" "\"\n")) (highlight scheme "(tabularize '((1 2 3) (4 5 6)) table-id: \"test\" even-row-class: \"yellow\" odd-row-class: \"blue\")") (p "Produces:") ((pre "\n\"" "<" "table id='test'" ">" "<" "tr class='yellow'" ">" "<" "td" ">" "1" "<" "/td" ">" "<" "td" ">" "2" "<" "/td" ">" "<" "td" ">" "3" "<" "/td" ">" "<" "/tr" ">" "<" "tr class='blue'" ">" "<" "td" ">" "4" "<" "/td" ">" "<" "td" ">" "5" "<" "/td" ">" "<" "td" ">" "6" "<" "/td" ">" "<" "/tr" ">" "<" "/table" ">" "\"\n"))))) (section 3 "License" (p "BSD")) (section 3 "Requirements" (p (int-link "/egg/html-tags" "html-tags"))) (section 3 "Version history" (section 4 "Version 0.10" (ul (li "New keyword parameters for " (tt "html-page") ": " (tt "html-attribs") " and " (tt "body-attribs") "."))) (section 4 "Version 0.9" (ul (li "Added " (tt "literal-style?") " and " (tt "content-type") " keyword parameters for " (tt "html-page") " ") (li (b "Warning") ": the default behavior for inlined CSS (" (tt "css") " keyword parameter for " (tt "html-page") ") has changed.  Now the special HTML  characters are converted to their corresponding entities in non-SXML mode (i.e., when " (int-link "/egg/html-tags" "html-tags") "' " (tt "generate-sxml?") " is " (tt "#f") " -- the default value).  This may break your page styles if you inline CSS via " (tt "html-page") "'s " (tt "css") " keyword parameter.  To get the old behavior, use " (tt "literal-style?: #t") " for " (tt "html-page") "."))) (section 4 "Version 0.8" (ul (li "Fixed order of elements in " (tt "<head>") ": " (tt "<meta http-equiv...>") " should be before " (tt "<title>") " (reported by Sandra Snan)"))) (section 4 "Version 0.7" (ul (li "Bugfix: " (tt "password-input") " was not being exported"))) (section 4 "Version 0.6" (ul (li "Added " (tt "thead/tbody") " keyword parameter for " (tt "tabularize")))) (section 4 "Version 0.5" (ul (li "Added the " (tt "password-input") " procedure and the " (tt "header") " keyword parameter for " (tt "tabularize")))) (section 4 "Version 0.5" (ul (li "Added " (tt "text-input") " and " (tt "submit-input")))) (section 4 "Version 0.1" (ul (li "Initial release"))))))