1Template::Plugin::HTML(U3s)er Contributed Perl DocumentatTieomnplate::Plugin::HTML(3)
2
3
4

NAME

6       Template::Plugin::HTML - Plugin to create HTML elements
7

SYNOPSIS

9           [% USE HTML %]
10
11           [% HTML.escape("if (a < b && c > d) ..." %]
12
13           [% HTML.element(table => { border => 1, cellpadding => 2 }) %]
14
15           [% HTML.attributes(border => 1, cellpadding => 2) %]
16

DESCRIPTION

18       The "HTML" plugin is a very basic plugin, implementing a few useful
19       methods for generating HTML.
20

METHODS

22   escape(text)
23       Returns the source text with any HTML reserved characters such as "<",
24       ">", etc., correctly esacped to their entity equivalents.
25
26   attributes(hash)
27       Returns the elements of the hash array passed by reference correctly
28       formatted (e.g. values quoted and correctly escaped) as attributes for
29       an HTML element.
30
31   element(type, attributes)
32       Generates an HTML element of the specified type and with the attributes
33       provided as an optional hash array reference as the second argument or
34       as named arguments.
35
36           [% HTML.element(table => { border => 1, cellpadding => 2 }) %]
37           [% HTML.element('table', border=1, cellpadding=2) %]
38           [% HTML.element(table => attribs) %]
39

DEBUGGING

41       The HTML plugin accepts a "sorted" option as a constructor argument
42       which, when set to any true value, causes the attributes generated by
43       the "attributes()" method (either directly or via "element()") to be
44       returned in sorted order.  Order of attributes isn't important in HTML,
45       but this is provided mainly for the purposes of debugging where it is
46       useful to have attributes generated in a deterministic order rather
47       than whatever order the hash happened to feel like returning the keys
48       in.
49
50           [% USE HTML(sorted=1) %]
51           [% HTML.element( foo => { charlie => 1, bravo => 2, alpha => 3 } ) %]
52
53       generates:
54
55           <foo alpha="3" bravo="2" charlie="1">
56

AUTHOR

58       Andy Wardley <abw@wardley.org> <http://wardley.org/>
59
61       Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
62
63       This module is free software; you can redistribute it and/or modify it
64       under the same terms as Perl itself.
65

SEE ALSO

67       Template::Plugin
68
69
70
71perl v5.16.3                      2011-12-20         Template::Plugin::HTML(3)
Impressum