Htmlgen | Writing HTML with Tcl | xmlgen |
Htmlgen — Writing HTML with Tcl
package require htmlgen
::htmlgen::htmltag ?attr=value ...? ?body ...?
(for every HTML tag)
::htmlgen::buffer varname body
::htmlgen::put ?arg ...?
::htmlgen::esc ?arg ...?
The package provides one Tcl command for every HTML tag. It allows to write structured Tcl code which, when executed, generates structured HTML output. The benefits are:
put/print/echo
commands.
In fact I consider htmlgen
to be what HTML should better
have been in the first place. The individual commands are
described below.
::htmlgen::a ?attr=value ...? ?ctrl? ?body ...?
::htmlgen::p ?attr=value ...? ?ctrl? ?body ...?
::htmlgen::table ?attr=value ...? ?ctrl? ?body ...?
::htmlgen::...
and so on for other tags.
Every such markup command takes a list of attribute-value pairs and one or more body arguments. It then generates HTML where the open tag contains all the attribute-value pairs and the close tag is never omitted. You can write
ul {style=color:red} ! {
li - one
li - two
}
to generate
<ul style="color:red">
<li>one</li>
<li>two</li>
</ul>
If the first argument which is not an attribute-value pair contains exactly one character, it is used to control the handling of the body according to the following table.
character | action |
---|---|
"!" | pass to [eval] and print |
"+" | pass to [subst] and print |
"-" | take as is and print |
"." (dot) | take as is and return |
(other) | error |
If the first non attribute-value argument has more than one character, it is considered to be the first body argument and the control character defaults to "." (dot) meaning that the body is taken as is, surrounded by the tags and then returned.
Please consult Generated Markup Commands in the manual page for xmlgen for the more details. It also describes, how attribute-value pairs are parsed.
::htmlgen::extra::tab ID url active tabs ?attr=value ...? ?body ...?
(experimental)
Creates table
based notebook tabs. Useful only for
CGI scripts. Nice layout in style-aware
browsers. Useful layout still in Navigator-4.7.
ID is the name of a variable you'll find with
::ncgi::parse
. The content of that variable is the name
of the selected tab. The available tabs are defined in
tabs which must be a list of pairs
tabname display, where
tabname is what you'll find in the CGI variable
$ID
and display is what is printed in the tab on
screen. Parameter active must be one of the given
tabname names. It will be rendered as the selected tab.
You can find an example in tab.tcl
::htmlgen::buffer varname body
::htmlgen::put ?arg ...?
::htmlgen::esc ?arg ...?
Overview, Xmlgen, Notebook Tabs, Navigation Bar
Htmlgen | 1.4 | xmlgen |