| 1 |
#============================================================= -*-Perl-*- |
| 2 |
# |
| 3 |
# Template::Plugin::View |
| 4 |
# |
| 5 |
# DESCRIPTION |
| 6 |
# A user-definable view based on templates. Similar to the concept of |
| 7 |
# a "Skin". |
| 8 |
# |
| 9 |
# AUTHOR |
| 10 |
# Andy Wardley <[email protected]> |
| 11 |
# |
| 12 |
# COPYRIGHT |
| 13 |
# Copyright (C) 2000-2007 Andy Wardley. All Rights Reserved. |
| 14 |
# |
| 15 |
# This module is free software; you can redistribute it and/or |
| 16 |
# modify it under the same terms as Perl itself. |
| 17 |
# |
| 18 |
#============================================================================ |
| 19 |
|
| 20 |
package Template::Plugin::View; |
| 21 |
|
| 22 |
use strict; |
| 23 |
use warnings; |
| 24 |
use base 'Template::Plugin'; |
| 25 |
|
| 26 |
our $VERSION = 2.68; |
| 27 |
|
| 28 |
use Template::View; |
| 29 |
|
| 30 |
#------------------------------------------------------------------------ |
| 31 |
# new($context, \%config) |
| 32 |
#------------------------------------------------------------------------ |
| 33 |
|
| 34 |
sub new { |
| 35 |
my $class = shift; |
| 36 |
my $context = shift; |
| 37 |
my $view = Template::View->new($context, @_) |
| 38 |
|| return $class->error($Template::View::ERROR); |
| 39 |
$view->seal(); |
| 40 |
return $view; |
| 41 |
} |
| 42 |
|
| 43 |
1; |
| 44 |
|
| 45 |
__END__ |
| 46 |
|
| 47 |
|
| 48 |
=head1 NAME |
| 49 |
|
| 50 |
Template::Plugin::View - Plugin to create views (Template::View) |
| 51 |
|
| 52 |
=head1 SYNOPSIS |
| 53 |
|
| 54 |
[% USE view( |
| 55 |
prefix = 'splash/' # template prefix/suffix |
| 56 |
suffix = '.tt2' |
| 57 |
bgcol = '#ffffff' # and any other variables you |
| 58 |
style = 'Fancy HTML' # care to define as view metadata, |
| 59 |
items = [ foo, bar.baz ] # including complex data and |
| 60 |
foo = bar ? baz : x.y.z # expressions |
| 61 |
%] |
| 62 |
|
| 63 |
[% view.title %] # access view metadata |
| 64 |
|
| 65 |
[% view.header(title = 'Foo!') %] # view "methods" process blocks or |
| 66 |
[% view.footer %] # templates with prefix/suffix added |
| 67 |
|
| 68 |
=head1 DESCRIPTION |
| 69 |
|
| 70 |
This plugin module creates L<Template::View> objects. Views are an |
| 71 |
experimental feature and are subject to change in the near future. |
| 72 |
In the mean time, please consult L<Template::View> for further info. |
| 73 |
|
| 74 |
=head1 AUTHOR |
| 75 |
|
| 76 |
Andy Wardley E<lt>[email protected]<gt> L<http://wardley.org/> |
| 77 |
|
| 78 |
=head1 COPYRIGHT |
| 79 |
|
| 80 |
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. |
| 81 |
|
| 82 |
This module is free software; you can redistribute it and/or |
| 83 |
modify it under the same terms as Perl itself. |
| 84 |
|
| 85 |
=head1 SEE ALSO |
| 86 |
|
| 87 |
L<Template::Plugin>, L<Template::View>, L<Template::Manual::Views> |
| 88 |
|
| 89 |
=cut |
| 90 |
|
| 91 |
# Local Variables: |
| 92 |
# mode: perl |
| 93 |
# perl-indent-level: 4 |
| 94 |
# indent-tabs-mode: nil |
| 95 |
# End: |
| 96 |
# |
| 97 |
# vim: expandtab shiftwidth=4: |