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::keywords args
76
77       ::html::mailto email ?subject?
78
79       ::html::meta args
80
81       ::html::minorMenu list ?sep?
82
83       ::html::minorList list ?ordered?
84
85       ::html::nl2br string
86
87       ::html::openTag tag args
88
89       ::html::passwordInput ?name?
90
91       ::html::passwordInputRow label ?name?
92
93       ::html::quoteFormValue value
94
95       ::html::radioSet key sep list
96
97       ::html::radioValue name value
98
99       ::html::refresh seconds url
100
101       ::html::init ?list?
102
103       ::html::row args
104
105       ::html::paramRow list ?rparam? ?cparam?
106
107       ::html::select name param choices ?current?
108
109       ::html::selectPlain name param choices ?current?
110
111       ::html::submit label ?name?
112
113       ::html::set var val
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::title title
126
127       ::html::varEmpty name
128
129       ::html::while test body
130
131_________________________________________________________________
132

DESCRIPTION

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

SEE ALSO

430       htmlparse, ncgi
431

KEYWORDS

433       checkbox, checkbutton, form, html, radiobutton, table
434
435
436
437html                                  1.4                              html(n)
Impressum