PApp::HTML - utility functions for html generation
use PApp::HTML;
This module provides a host of HTML-related convenience functions, most of which output HTML elements.
Returns the html-escaped version of $arg (escaping characters like '<' and '&', as well as any whitespace characters other than space, cr and lf).
$arg
Returns the uri-escaped version of $arg, escaping characters like ' ' (space) and ';' into url-escaped-form using %hex-code. This function encodes characters with code >255 as utf-8 characters.
Returns the attribute-escaped version of $arg (it also wraps its argument into single quotes, so don't do that yourself).
Render a two-part error-box, very distinctive, very ugly, very visible!
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).
attrs
$value
textfield
checkbox
Return an XHTML element with the given tagname, optional attributes and content. img, br and input elements are handled specially (content model empty).
img
br
input
Create "a link" (a href) with the given contents, pointing at the given url. It uses single quotes to delimit the url, so watch out and escape yourself!
Submits a graphical submit button. $img_url must be the url to the image that is to be used.
$img_url
Creates an input element of type text named $name. Examples:
$name
textfield "field1"; textfield "field1", "some text"; textfield { maxlength => 20 }, "field1";
Creates an input element of type textarea named $name
Creates an input element of type password named $name
Creates an input element of type hidden named $name
Creates an input element of type checkbox named $name
Creates an input element of type radiobutton named $name
Creates an input element of type file named $name
Creates an input element of type select(box) named $name. $selected should be the currently selected value (or an arrayref containing all selected values). All remaining arguments are treated as name (displayed) => value (submitted) pairs.
$selected
Returns a script element containing correctly quoted code inside a comment as recommended in HTML 4. Every occurence of -- 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>
Create a mailto url with the specified headers (see RFC 2368). All values will be properly escaped for you. Example:
mailto_url "schmorp\@schmorp.de", subject => "Mail from me", body => "hello, world!";
PApp, PApp::XML.
Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/
To install PApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PApp
CPAN shell
perl -MCPAN -e shell install PApp
For more information on module installation, please visit the detailed CPAN module installation guide.