| 1 |
#============================================================= -*-Perl-*- |
| 2 |
# |
| 3 |
# Template::Plugin::Iterator |
| 4 |
# |
| 5 |
# DESCRIPTION |
| 6 |
# |
| 7 |
# Plugin to create a Template::Iterator from a list of items and optional |
| 8 |
# configuration parameters. |
| 9 |
# |
| 10 |
# AUTHOR |
| 11 |
# Andy Wardley <[email protected]> |
| 12 |
# |
| 13 |
# COPYRIGHT |
| 14 |
# Copyright (C) 2000-2007 Andy Wardley. All Rights Reserved. |
| 15 |
# |
| 16 |
# This module is free software; you can redistribute it and/or |
| 17 |
# modify it under the same terms as Perl itself. |
| 18 |
# |
| 19 |
#============================================================================ |
| 20 |
|
| 21 |
package Template::Plugin::Iterator; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use base 'Template::Plugin'; |
| 26 |
use Template::Iterator; |
| 27 |
|
| 28 |
our $VERSION = 2.68; |
| 29 |
|
| 30 |
#------------------------------------------------------------------------ |
| 31 |
# new($context, \@data, \%args) |
| 32 |
#------------------------------------------------------------------------ |
| 33 |
|
| 34 |
sub new { |
| 35 |
my $class = shift; |
| 36 |
my $context = shift; |
| 37 |
Template::Iterator->new(@_); |
| 38 |
} |
| 39 |
|
| 40 |
1; |
| 41 |
|
| 42 |
__END__ |
| 43 |
|
| 44 |
=head1 NAME |
| 45 |
|
| 46 |
Template::Plugin::Iterator - Plugin to create iterators (Template::Iterator) |
| 47 |
|
| 48 |
=head1 SYNOPSIS |
| 49 |
|
| 50 |
[% USE iterator(list, args) %] |
| 51 |
|
| 52 |
[% FOREACH item = iterator %] |
| 53 |
[% '<ul>' IF iterator.first %] |
| 54 |
<li>[% item %] |
| 55 |
[% '</ul>' IF iterator.last %] |
| 56 |
[% END %] |
| 57 |
|
| 58 |
=head1 DESCRIPTION |
| 59 |
|
| 60 |
The iterator plugin provides a way to create a L<Template::Iterator> object |
| 61 |
to iterate over a data set. An iterator is implicitly automatically by the |
| 62 |
L<FOREACH> directive. This plugin allows the iterator to be explicitly created |
| 63 |
with a given name. |
| 64 |
|
| 65 |
=head1 AUTHOR |
| 66 |
|
| 67 |
Andy Wardley E<lt>[email protected]<gt> L<http://wardley.org/> |
| 68 |
|
| 69 |
=head1 COPYRIGHT |
| 70 |
|
| 71 |
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. |
| 72 |
|
| 73 |
This module is free software; you can redistribute it and/or |
| 74 |
modify it under the same terms as Perl itself. |
| 75 |
|
| 76 |
=head1 SEE ALSO |
| 77 |
|
| 78 |
L<Template::Plugin>, L<Template::Iterator> |
| 79 |
|
| 80 |
=cut |
| 81 |
|
| 82 |
# Local Variables: |
| 83 |
# mode: perl |
| 84 |
# perl-indent-level: 4 |
| 85 |
# indent-tabs-mode: nil |
| 86 |
# End: |
| 87 |
# |
| 88 |
# vim: expandtab shiftwidth=4: |