PApp::HTML - utility functions for html generation
$arg
(escaping characters like '<'
and '&', as well as any whitespace characters other than space, cr and
lf).
$arg
, escaping characters like ' '
(space) and ';' into url-escaped-form using %hex-code. This function
encodes characters with code >255 as utf-8 characters.
$arg
(it also wraps its
argument into single quotes, so don't do that yourself).
The following functions are shortcuts to various often-used html tags
(mostly form elements). All of them allow an initial
argument attrs
of type hashref which can contain attribute => value
pairs. Attributes always required for the given element (e.g.
``name'' for form-elements) can usually be specified directly without using
that hash. $value
is usually the initial state/content of the
input element (e.g. some text for textfield
or boolean for checkbox
).
img
, br
and input
elements are handled specially
(content model empty).
$img_url
must be the url to the image that is to be used.
$name
. Examples:
textfield "field1"; textfield "field1", "some text"; textfield { maxlength => 20 }, "field1";
$name
$name
$name
$name
$name
$name
select(box)
named $name
. $selected
should be the currently selected value (or an arrayref containing all
selected values). All remaining arguments are trated as name (displayed)
=> value (submitted) pairs.
--
will be replaced by
-\-
to avoid generating illegal syntax (for XHTML compatibility). Yes,
this means that the decrement operator is certainly out. One would expect
browsers to properly support entities inside script tags, but of course
they don't, ruling better solutions totally out.
If you use a stylesheet, consider something like this for your head-section:
<script type="text/javascript" language="javascript1.3" defer="defer"> <xsl:comment> <xsl:text> </xsl:text> <xsl:for-each select="descendant::script"> <xsl:text disable-output-escaping="yes"><xsl:value-of select="text()"/></xsl:text> </xsl:for-each> <xsl:text>//</xsl:text> </xsl:comment> </script>
mailto_url "pcg@goof.com", subject => "Mail from me", body => "(generated from ".reference_url(1).")";
Marc Lehmann <pcg@goof.com> http://www.goof.com/pcg/marc/