1html(n)                         HTML Generation                        html(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       html - Procedures to generate HTML structures
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require html  ?1.4?
14
15       ::html::author author
16
17       ::html::bodyTag args
18
19       ::html::cell param value ?tag?
20
21       ::html::checkbox name value
22
23       ::html::checkSet key sep list
24
25       ::html::checkValue name ?value?
26
27       ::html::closeTag
28
29       ::html::default key ?param?
30
31       ::html::description description
32
33       ::html::end
34
35       ::html::eval arg ?args?
36
37       ::html::extractParam param key ?varName?
38
39       ::html::font args
40
41       ::html::for start test next body
42
43       ::html::foreach varlist1 list1 ?varlist2 list2 ...? body
44
45       ::html::formValue name ?defvalue?
46
47       ::html::getFormInfo args
48
49       ::html::getTitle
50
51       ::html::h level string ?param?
52
53       ::html::h1 string ?param?
54
55       ::html::h2 string ?param?
56
57       ::html::h3 string ?param?
58
59       ::html::h4 string ?param?
60
61       ::html::h5 string ?param?
62
63       ::html::h6 string ?param?
64
65       ::html::hdrRow args
66
67       ::html::head title
68
69       ::html::headTag string
70
71       ::html::html_entities string
72
73       ::html::if expr1 body1 ?elseif expr2 body2 ...? ?else bodyN?
74
75       ::html::init ?list?
76
77       ::html::keywords args
78
79       ::html::mailto email ?subject?
80
81       ::html::meta args
82
83       ::html::minorList list ?ordered?
84
85       ::html::minorMenu list ?sep?
86
87       ::html::nl2br string
88
89       ::html::openTag tag ?param?
90
91       ::html::paramRow list ?rparam? ?cparam?
92
93       ::html::passwordInput ?name?
94
95       ::html::passwordInputRow label ?name?
96
97       ::html::quoteFormValue value
98
99       ::html::radioSet key sep list
100
101       ::html::radioValue name value
102
103       ::html::refresh seconds url
104
105       ::html::row args
106
107       ::html::select name param choices ?current?
108
109       ::html::selectPlain name param choices ?current?
110
111       ::html::set var val
112
113       ::html::submit label ?name?
114
115       ::html::tableFromArray arrname ?param? ?pat?
116
117       ::html::tableFromList querylist ?param?
118
119       ::html::textarea name ?param? ?current?
120
121       ::html::textInput name value args
122
123       ::html::textInputRow label name value args
124
125       ::html::varEmpty name
126
127       ::html::while test body
128
129_________________________________________________________________
130

DESCRIPTION

132       The  package html provides commands that generate HTML.  These commands
133       typically return an HTML string as their result. In particular, they do
134       not output their result to stdout.
135
136       The  command ::html::init should be called early to initialize the mod‐
137       ule.  You can also use this procedure to define default values for HTML
138       tag parameters.
139
140       ::html::author author
141              Side  effect  only.   Call this before ::html::head to define an
142              author for the page.  The author is noted in a  comment  in  the
143              HEAD section.
144
145       ::html::bodyTag args
146              Generate  a body tag.  The tag parameters are taken from args or
147              from the body.* attributes define with ::html::init.
148
149       ::html::cell param value ?tag?
150              Generate a td (or th) tag, a value, and a  closing  td  (or  th)
151              tag.  The  tag  parameters  come  from  param or TD.* attributes
152              defined with ::html::init.  This uses ::html::font to  insert  a
153              standard font tag into the table cell. The tag argument defaults
154              to "td".
155
156       ::html::checkbox name value
157              Generate a checkbox form element with  the  specified  name  and
158              value.  This uses ::html::checkValue.
159
160       ::html::checkSet key sep list
161              Generate  a set of checkbox form elements and associated labels.
162              The list should contain an alternating list of labels  and  val‐
163              ues.  This uses ::html::checkbox. All the checkbox buttons share
164              the same key for their name. The sep is text  used  to  separate
165              the elements.
166
167       ::html::checkValue name ?value?
168              Generate the "name=name value=value for a checkbox form element.
169              If the CGI variable name has the value value, then  SELECTED  is
170              added to the return value. value defaults to "1".
171
172       ::html::closeTag
173              Pop  a tag off the stack created by ::html::openTag and generate
174              the corresponding close tag (e.g., </body>).
175
176       ::html::default key ?param?
177              This procedure is used by ::html::tagParam to generate the name,
178              value  list of parameters for a tag.  The ::html::default proce‐
179              dure is used to generate default  values  for  those  items  not
180              already  in  param.   If  the  value identified by key matches a
181              value in param then this procedure  returns  the  empty  string.
182              Otherwise, it returns a "parameter=value" string for a form ele‐
183              ment identified by key.  The key has  the  form  "tag.parameter"
184              (e.g., body.bgcolor).  Use ::html::init to register default val‐
185              ues. param defaults to the empty string.
186
187       ::html::description description
188              Side effect only.  Call this before  ::html::head  to  define  a
189              description  meta tag for the page.  This tag is generated later
190              in the call to ::html::head.
191
192       ::html::end
193              Pop all open tags from the stack and generate the  corresponding
194              close HTML tags, (e.g., </body></html>).
195
196       ::html::eval arg ?args?
197              This procedure is similar to the built-in Tcl eval command.  The
198              only difference is that it returns "" so it can be  called  from
199              an HTML template file without appending unwanted results.
200
201       ::html::extractParam param key ?varName?
202              This  is a parsing procedure that extracts the value of key from
203              param, which is a HTML-style "name=quotedvalue"  list.   varName
204              is  used  as  the name of a Tcl variable that is changed to have
205              the value found in the parameters.  The function  returns  1  if
206              the  parameter  was  found in param, otherwise it returns 0.  If
207              the varName is not specified, then key is used as  the  variable
208              name.
209
210       ::html::font args
211              Generate  a  standard  font  tag.  The parameters to the tag are
212              taken from args and the HTML defaults defined with ::html::init.
213
214       ::html::for start test next body
215              This procedure is similar to the built-in Tcl for control struc‐
216              ture.   Rather than evaluating the body, it returns the subst'ed
217              body. Each iteration of the loop causes  another  string  to  be
218              concatenated to the result value.
219
220       ::html::foreach varlist1 list1 ?varlist2 list2 ...? body
221              This  procedure  is  similar to the built-in Tcl foreach control
222              structure.  Rather than evaluating  the  body,  it  returns  the
223              subst'ed body.  Each iteration of the loop causes another string
224              to be concatenated to the result value.
225
226       ::html::formValue name ?defvalue?
227              Return a name and value pair, where  the  value  is  initialized
228              from existing CGI data, if any.  The result has this form:
229
230
231                name="fred" value="freds value"
232
233
234       ::html::getFormInfo args
235              Generate  hidden  fields  to  capture  form  values.  If args is
236              empty, then hidden fields are  generated  for  all  CGI  values.
237              Otherwise  args is a list of string match patterns for form ele‐
238              ment names.
239
240       ::html::getTitle
241              Return the title string, with out the surrounding title tag, set
242              with a previous call to ::html::title.
243
244       ::html::h level string ?param?
245              Generate  a heading (e.g., hlevel) tag.  The string is nested in
246              the heading, and param is used for the tag parameters.
247
248       ::html::h1 string ?param?
249              Generate an h1 tag.  See ::html::h.
250
251       ::html::h2 string ?param?
252              Generate an h2 tag.  See ::html::h.
253
254       ::html::h3 string ?param?
255              Generate an h3 tag.  See ::html::h.
256
257       ::html::h4 string ?param?
258              Generate an h4 tag.  See ::html::h.
259
260       ::html::h5 string ?param?
261              Generate an h5 tag.  See ::html::h.
262
263       ::html::h6 string ?param?
264              Generate an h6 tag.  See ::html::h.
265
266       ::html::hdrRow args
267              Generate a table row, including tr and th tags.  Each  value  in
268              args is place into its own table cell.  This uses ::html::cell.
269
270       ::html::head title
271              Generate the head section that includes the page title.  If pre‐
272              vious calls have been made to ::html::author,  ::html::keywords,
273              ::html::description,  or  ::html::meta  then additional tags are
274              inserted into the head section.  This leaves an  open  html  tag
275              pushed on the stack with ::html::openTag.
276
277       ::html::headTag string
278              Save  a  tag  for  inclusion  in  the  head section generated by
279              ::html::head.  The string is everything in the  tag  except  the
280              enclosing angle brackets, < >.
281
282       ::html::html_entities string
283              This  command replaces all special characters in the string with
284              their HTML entities and returns the modified text.
285
286       ::html::if expr1 body1 ?elseif expr2 body2 ...? ?else bodyN?
287              This procedure is similar to the built-in Tcl if control  struc‐
288              ture.   Rather  than  evaluating  the body of the branch that is
289              taken, it returns the subst'ed body.  Note that  the  syntax  is
290              slightly  more restrictive than that of the built-in Tcl if con‐
291              trol structure.
292
293       ::html::init ?list?
294              ::html::init accepts a Tcl-style name-value  list  that  defines
295              values  for  items with a name of the form "tag.parameter".  For
296              example, a default with key  "body.bgcolor"  defines  the  back‐
297              ground color for the body tag.
298
299       ::html::keywords args
300              Side  effect  only.   Call  this before ::html::head to define a
301              keyword meta tag for the page.  The meta tag is included in  the
302              result of ::html::head.
303
304       ::html::mailto email ?subject?
305              Generate a hypertext link to a mailto: URL.
306
307       ::html::meta args
308              Side  effect  only.   Call  this before ::html::head to define a
309              meta tag for the page.  The args is a Tcl-style name, value list
310              that  is  used  for the name= and value= parameters for the meta
311              tag.  The meta tag is included in the result of ::html::head.
312
313       ::html::minorList list ?ordered?
314              Generate an ordered or unordered list of links.  The list  is  a
315              Tcl-style  name,  value  list  of labels and urls for the links.
316              ordered is a boolean  used  to  choose  between  an  ordered  or
317              unordered list. It defaults to false.
318
319       ::html::minorMenu list ?sep?
320              Generate  a  series of hypertext links.  The list is a Tcl-style
321              name, value list of labels and urls for the links.  The  sep  is
322              the text to put between each link. It defaults to " | ".
323
324       ::html::nl2br string
325              This  command  replaces all line-endings in the string with a br
326              tag and returns the modified text.
327
328       ::html::openTag tag ?param?
329              Push tag onto a stack and generate the opening tag for tag.  Use
330              ::html::closeTag to pop the tag from the stack. The second argu‐
331              ment provides any tag arguments, as a list  whose  elements  are
332              formatted to be in the form "key=value".
333
334       ::html::paramRow list ?rparam? ?cparam?
335              Generate  a  table  row, including tr and td tags. Each value in
336              list is placed into its own table cell. This uses  ::html::cell.
337              The  value  of  rparam  is used as parameter for the tr tag. The
338              value of cparam is passed to ::html::cell as parameter  for  the
339              td tags.
340
341       ::html::passwordInput ?name?
342              Generate  an  input  tag  of type password. The name defaults to
343              "password".
344
345       ::html::passwordInputRow label ?name?
346              Format a table row containing a label and an input tag  of  type
347              password. The name defaults to "password".
348
349       ::html::quoteFormValue value
350              Quote  special  characters  in value by replacing them with HTML
351              entities for quotes, ampersand, and angle brackets.
352
353       ::html::radioSet key sep list
354              Generate a set of input tags of type  radio  and  an  associated
355              text  label.  All the radio buttons share the same key for their
356              name.  The sep is text used to separate the elements.  The  list
357              is a Tcl-style label, value list.
358
359       ::html::radioValue name value
360              Generate  the  "name=name  value=value for a radio form element.
361              If the CGI variable name has the value value, then  SELECTED  is
362              added to the return value.
363
364       ::html::refresh seconds url
365              Set up a refresh meta tag. Call this before ::html::head and the
366              HEAD section will contain a meta tag that causes the document to
367              refresh in seconds seconds.  The url is optional.  If specified,
368              it specifies a new page to load after the refresh interval.
369
370       ::html::row args
371              Generate a table row, including tr and td tags.  Each  value  in
372              args  is  place into its own table cell. This uses ::html::cell.
373              Ignores any default information set up via ::html::init.
374
375       ::html::select name param choices ?current?
376              Generate a select form element and nested option tags. The  name
377              and  param are used to generate the select tag. The choices list
378              is a Tcl-style name, value list.
379
380       ::html::selectPlain name param choices ?current?
381              Like ::html::select except that choices is a Tcl list of  values
382              used  for  the  option  tags.   The label and the value for each
383              option are the same.
384
385       ::html::set var val
386              This procedure is similar to the built-in Tcl set command.   The
387              main  difference  is that it returns "" so it can be called from
388              an HTML template file without appending unwanted  results.   The
389              other difference is that it must take two arguments.
390
391       ::html::submit label ?name?
392              Generate an input tag of type submit. name defaults to "submit".
393
394       ::html::tableFromArray arrname ?param? ?pat?
395              Generate  a  two-column  table  and nested rows to display a Tcl
396              array. The table gets a heading that matches the array name, and
397              each  generated row contains a name, value pair. The array names
398              are sorted (lsort without special options). The  argument  param
399              is  for the table tag and has to contain a pre-formatted string.
400              The pat is a string match pattern used to select the array  ele‐
401              ments  to  show  in  the table. It defaults to *, i.e. the whole
402              array is shown.
403
404       ::html::tableFromList querylist ?param?
405              Generate  a  two-column  table  and  nested  rows   to   display
406              querylist,  which  is  a Tcl dictionary. Each generated row con‐
407              tains a name, value pair. The information is shown in  the  same
408              order  as specified in the dictionary. The argument param is for
409              the table tag  and has to contain a pre-formatted string.
410
411       ::html::textarea name ?param? ?current?
412              Generate a textarea tag wrapped around its current values.
413
414       ::html::textInput name value args
415              Generate  an  input  form  tag  with  type  text.    This   uses
416              ::html::formValue.   The  args  is any additional tag attributes
417              you want to put into the input tag.
418
419       ::html::textInputRow label name value args
420              Generate an input form tag with type text formatted into a table
421              row  with  an  associated label.  The args is any additional tag
422              attributes you want to put into the input tag.
423
424       ::html::varEmpty name
425              This returns 1 if the named variable either does  not  exist  or
426              has the empty string for its value.
427
428       ::html::while test body
429              This  procedure  is  similar  to  the built-in Tcl while control
430              structure.  Rather than evaluating  the  body,  it  returns  the
431              subst'ed body.  Each iteration of the loop causes another string
432              to be concatenated to the result value.
433

BUGS, IDEAS, FEEDBACK

435       This document, and the package it describes, will  undoubtedly  contain
436       bugs  and  other  problems.  Please report such in the category html of
437       the         Tcllib         SF         Trackers          [http://source
438       forge.net/tracker/?group_id=12883].   Please  also report any ideas for
439       enhancements you may have for either package and/or documentation.
440

SEE ALSO

442       htmlparse, ncgi
443

KEYWORDS

445       checkbox, checkbutton, form, html, radiobutton, table
446
447
448
449html                                  1.4                              html(n)
Impressum