Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

html-utils

  1. Outdated egg!
  2. html-utils
    1. Introduction
    2. Author
    3. Procedures
      1. itemize
      2. enumerate
      3. html-page
      4. combo-box
      5. hidden-input
      6. text-input
      7. password-input
      8. submit-input
      9. tabularize
    4. License
    5. Requirements
    6. Version history
      1. Version 0.10
      2. Version 0.9
      3. Version 0.8
      4. Version 0.7
      5. Version 0.6
      6. Version 0.5
      7. Version 0.5
      8. Version 0.1

Introduction

html-utils is an extension which provides procedures to ease the generation of some frequently used [SX]HTML structures.

html-utils is based on html-tags, so it can generate strings or SXML code. The html-tags' generate-sxml? parameter (yields a boolean) specifies whether html-utils should generate strings or SXML code.

Example:

 $ csi -n
 #;1> (use html-tags html-utils)
 #;2> (generate-sxml?)
 #f
 #;3> (itemize '(1 2 3))
 "<ul><li>1</li><li>2</li><li>3</li></ul>"
 #;4> (generate-sxml? #t)
 #t
 #;5> (itemize '(1 2 3))
 (ul (li 1) (li 2) (li 3))

Author

Mario Domenech Goulart

Procedures

itemize

[procedure] (itemize items #!key list-id list-class quote-procedure)

Generates an HTML unordered list of items. The following attributes may be used:

Examples:

(itemize '(apple watermelon strawberry))

Produces:

 "<ul><li>apple</li><li>watermelon</li><li>strawberry</li></ul>"
(itemize '(apple watermelon strawberry) list-id: "my-list" list-class: "lists")

Produces:

 "<ul id='my-list' class='lists'><li>apple</li><li>watermelon</li><li>strawberry</li></ul>"

enumerate

[procedure] (enumerate items #!key list-id list-class quote-procedure)

Generates an HTML ordered list of items. See itemize.

html-page

[procedure] (html-page contents #!key css title (doctype "") (headers "") charset content-type literal-style? html-attribs body-attribs)

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:

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"))

combo-box

[procedure] (combo-box name options #!key default id first-empty onchange onkeyup disabled length multiple selectedindex size tabindex type class)

Generates an HTML combo box using <select> and <option> tags. The keyword parameters id, onchange, onkeyup, disabled, length, multiple, selectedindex, size, tabindex, type and class are passed to the <select> procedure (from html-tags). default is the value from the list of options to be selected. If first-empty is #t, the first option of the combo box will be empty.

Example:

(combo-box "test" '(#(1 1) #(2 2) #(3 3)) first-empty: #t default: 2)

Produces:

"<select name='test' id='test'><option></option><option value='1'>1</option><option value='2' selected>2</option><option value='3'>3</option></select>"

hidden-input

[procedure] (hidden-input name/list #!optional value id)

Generates an HTML hidden input field. 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 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.

Examples:

(hidden-input 'secret-var "secret-val")

Produces:

 "<input type='hidden' name='secret-var' id='secret-var' value='secret-val'>"
(hidden-input '((secret-var1 . "secret-val1") (secret-var2 . "secret-val2")))

Produces:

 "<input type='hidden' id='secret-var1' name='secret-var1' value='secret-val1'><input type='hidden' id='secret-var2' name='secret-var2' value='secret-val2'>"

text-input

[procedure] (text-input name . args)

Generates an input text box. args are keyword arguments to be passed to <input> (from html-tags).

Examples:

(text-input "foo" value: "bar")

Produces:

 "<input type='text' name='foo' id='foo' value='bar'>"

password-input

[procedure] (password-input name . args)

The same as text-input, but for password inputs.

submit-input

[procedure] (submit-input . args)

Generates a submit widget. args are keyword arguments to be passed to <input> (from html-tags).

 (submit-input value: "Send!")

Produces:

 "<input type='submit' value='Send!'>"

tabularize

[procedure] (tabularize items #!key table-id table-class quote-procedure even-row-class odd-row-class header)

Generates an HTML table from items (a list of lists). The following keyword parameters may be used:

Examples:

(tabularize '((1 2 3) (4 5 6)))

Produces:


"<table><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr></table>"
(tabularize '((1 2 3) (4 5 6)) table-id: "test" even-row-class: "yellow" odd-row-class: "blue")

Produces:


"<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>"

License

BSD

Requirements

html-tags

Version history

Version 0.10

Version 0.9

Version 0.8

Version 0.7

Version 0.6

Version 0.5

Version 0.5

Version 0.1