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 very new and very basic, implementing a few useful
19       methods for generating HTML.  It is likely to be extended in the future
20       or integrated with a larger project to generate HTML elements in a
21       generic way (as discussed recently on the mod_perl mailing list).
22

METHODS

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

DEBUGGING

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

AUTHOR

63       Andy Wardley <abw@wardley.org>
64
65       <http://wardley.org/http://wardley.org/>
66

VERSION

68       2.62, distributed as part of the Template Toolkit version 2.18,
69       released on 09 February 2007.
70
72         Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
73
74       This module is free software; you can redistribute it and/or modify it
75       under the same terms as Perl itself.
76

SEE ALSO

78       Template::Plugin
79
80
81
82perl v5.8.8                       2007-02-09         Template::Plugin::HTML(3)
Impressum