/usr/lib/perl5/Template/Manual/Plugins.pod is in libtemplate-perl 2.22-0.1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | #============================================================= -*-perl-*-
#
# Template::Manual::Plugins
#
# AUTHOR
# Andy Wardley <abw@wardley.org>
#
# COPYRIGHT
# Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
#========================================================================
=head1 NAME
Template::Manual::Plugins - Standard plugins
=head1 TEMPLATE TOOLKIT PLUGINS
The following plugin modules are distributed with the Template
Toolkit. Some of the plugins interface to external modules (detailed
below) which should be downloaded from any CPAN site and installed
before using the plugin.
=head2 Assert
New in 2.20! The L<Assert|Template::Plugin::Assert> plugin adds an
C<assert> virtual method that you can use to catch undefined values.
For example, consider this dotop:
[% user.name %]
If C<user.name> is an undefined value then TT will silently ignore the
fact and print nothing. If you C<USE> the C<assert> plugin then you
can add the C<assert> vmethod between the C<user> and C<name> elements,
like so:
[% user.assert.name %]
Now, if C<user.name> is an undefined value, an exception will be thrown:
assert error - undefined value for name
=head2 Autoformat
The L<Autoformat|Template::Plugin::Autoformat> plugin is an interface to
Damian Conway's L<Text::Autoformat> Perl module which provides advanced text
wrapping and formatting. See L<Template::Plugin::Autoformat> and
L<Text::Autoformat> for further details.
[% USE autoformat(left=10, right=20) %]
[% autoformat(mytext) %] # call autoformat sub
[% mytext FILTER autoformat %] # or use autoformat filter
The L<Text::Autoformat> module is available from CPAN:
L<http://www.cpan.org/modules/by-module/Text/>
=head2 CGI
The L<CGI|Template::Plugin::CGI> plugin is a wrapper around Lincoln Stein's
CGI.pm module. The plugin is distributed with the Template Toolkit (see
L<Template::Plugin::CGI>) and the L<CGI> module itself is distributed with
recent versions Perl, or is available from CPAN.
[% USE CGI %]
[% CGI.param('param_name') %]
[% CGI.start_form %]
[% CGI.popup_menu( Name => 'color',
Values => [ 'Green', 'Brown' ] ) %]
[% CGI.end_form %]
=head2 Datafile
Provides an interface to data stored in a plain text file in a simple
delimited format. The first line in the file specifies field names
which should be delimiter by any non-word character sequence.
Subsequent lines define data using the same delimiter as in the first
line. Blank lines and comments (lines starting '#') are ignored. See
L<Template::Plugin::Datafile> for further details.
/tmp/mydata:
# define names for each field
id : email : name : tel
# here's the data
fred : fred@here.com : Fred Smith : 555-1234
bill : bill@here.com : Bill White : 555-5678
example:
[% USE userlist = datafile('/tmp/mydata') %]
[% FOREACH user = userlist %]
[% user.name %] ([% user.id %])
[% END %]
=head2 Date
The L<Date|Template::Plugin::Date> plugin provides an easy way to generate
formatted time and date strings by delegating to the L<POSIX> C<strftime()>
routine. See L<Template::Plugin::Date> and L<POSIX> for further details.
[% USE date %]
[% date.format %] # current time/date
File last modified: [% date.format(template.modtime) %]
=head2 Directory
The L<Directory|Template::Plugin::Directory> plugin provides a simple
interface to a directory and the files within it. See
L<Template::Plugin::Directory> for further details.
[% USE dir = Directory('/tmp') %]
[% FOREACH file = dir.files %]
# all the plain files in the directory
[% END %]
[% FOREACH file = dir.dirs %]
# all the sub-directories
[% END %]
=head2 DBI
The C<DBI> plugin is no longer distributed as part of the Template Toolkit
(as of version 2.15). It is now available as a separate L<Template::DBI>
distribution from CPAN.
=head2 Dumper
The L<Dumper|Template::Plugin::Dumper> plugin provides an interface to the
Data::Dumper module. See L<Template::Plugin::Dumper> and L<Data::Dumper> for
futher details.
[% USE dumper(indent=0, pad="<br>") %]
[% dumper.dump(myvar, yourvar) %]
=head2 File
The L<File|Template::Plugin::File> plugin provides a general abstraction for
files and can be used to fetch information about specific files within a
filesystem. See L<Template::Plugin::File> for further details.
[% USE File('/tmp/foo.html') %]
[% File.name %] # foo.html
[% File.dir %] # /tmp
[% File.mtime %] # modification time
=head2 Filter
This module implements a base class plugin which can be subclassed
to easily create your own modules that define and install new filters.
package MyOrg::Template::Plugin::MyFilter;
use Template::Plugin::Filter;
use base qw( Template::Plugin::Filter );
sub filter {
my ($self, $text) = @_;
# ...mungify $text...
return $text;
}
Example of use:
# now load it...
[% USE MyFilter %]
# ...and use the returned object as a filter
[% FILTER $MyFilter %]
...
[% END %]
See L<Template::Plugin::Filter> for further details.
=head2 Format
The L<Format|Template::Plugin::Format> plugin provides a simple way to format
text according to a C<printf()>-like format. See L<Template::Plugin::Format> for
further details.
[% USE bold = format('<b>%s</b>') %]
[% bold('Hello') %]
=head2 GD
The C<GD> plugins are no longer part of the core Template Toolkit distribution.
They are now available from CPAN in a separate L<Template::GD> distribution.
=head2 HTML
The L<HTML|Template::Plugin::HTML> plugin is very basic, implementing a few
useful methods for generating HTML. It is likely to be extended in the future
or integrated with a larger project to generate HTML elements in a generic way.
[% USE HTML %]
[% HTML.escape("if (a < b && c > d) ..." %]
[% HTML.attributes(border => 1, cellpadding => 2) %]
[% HTML.element(table => { border => 1, cellpadding => 2 }) %]
See L<Template::Plugin::HTML> for further details.
=head2 Iterator
The L<Iterator|Template::Plugin::Iterator> plugin provides a way to create a
L<Template::Iterator> object to iterate over a data set. An iterator is
created automatically by the C<FOREACH> directive and is aliased to the C<loop>
variable. This plugin allows an iterator to be explicitly created with a given
name, or the default plugin name, C<iterator>. See
L<Template::Plugin::Iterator> for further details.
[% USE iterator(list, args) %]
[% FOREACH item = iterator %]
[% '<ul>' IF iterator.first %]
<li>[% item %]
[% '</ul>' IF iterator.last %]
[% END %]
=head2 Pod
This plugin provides an interface to the L<Pod::POM|Pod::POM> module
which parses POD documents into an internal object model which can
then be traversed and presented through the Template Toolkit.
[% USE Pod(podfile) %]
[% FOREACH head1 = Pod.head1;
FOREACH head2 = head1/head2;
...
END;
END
%]
=head2 Scalar
The Template Toolkit calls user-defined subroutines and object methods
using Perl's array context by default.
# TT2 calls object methods in array context by default
[% object.method %]
This plugin module provides a way for you to call subroutines and methods
in scalar context.
[% USE scalar %]
# force it to use scalar context
[% object.scalar.method %]
# also works with subroutine references
[% scalar.my_sub_ref %]
=head2 String
The L<String|Template::Plugin::String> plugin implements an object-oriented
interface for manipulating strings. See L<Template::Plugin::String> for
further details.
[% USE String 'Hello' %]
[% String.append(' World') %]
[% msg = String.new('Another string') %]
[% msg.replace('string', 'text') %]
The string "[% msg %]" is [% msg.length %] characters long.
=head2 Table
The L<Table|Template::Plugin::Table> plugin allows you to format a list of
data items into a virtual table by specifying a fixed number of rows or
columns, with an optional overlap. See L<Template::Plugin::Table> for further
details.
[% USE table(list, rows=10, overlap=1) %]
[% FOREACH item = table.col(3) %]
[% item %]
[% END %]
=head2 URL
The L<URL|Template::Plugin::URL> plugin provides a simple way of contructing
URLs from a base part and a variable set of parameters. See
L<Template::Plugin::URL> for further details.
[% USE mycgi = url('/cgi-bin/bar.pl', debug=1) %]
[% mycgi %]
# ==> /cgi/bin/bar.pl?debug=1
[% mycgi(mode='submit') %]
# ==> /cgi/bin/bar.pl?mode=submit&debug=1
=head2 Wrap
The L<Wrap|Template::Plugin::Wrap> plugin uses the L<Text::Wrap> module to
provide simple paragraph formatting. See L<Template::Plugin::Wrap> and
L<Text::Wrap> for further details.
[% USE wrap %]
[% wrap(mytext, 40, '* ', ' ') %] # use wrap sub
[% mytext FILTER wrap(40) -%] # or wrap FILTER
The C<Text::Wrap> module is available from CPAN:
http://www.cpan.org/modules/by-module/Text/
=head2 XML
The C<XML::DOM>, C<XML::RSS>, C<XML::Simple> and C<XML::XPath> plugins are no
longer distributed with the Template Toolkit as of version 2.15
They are now available in a separate L<Template::XML> distribution.
=cut
# Local Variables:
# mode: perl
# perl-indent-level: 4
# indent-tabs-mode: nil
# End:
#
# vim: expandtab shiftwidth=4:
|