line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
20797
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
133
|
|
3
|
|
|
|
|
|
|
package Module::Starter::Plugin::TT2; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.125'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1957
|
use Template; |
|
1
|
|
|
|
|
30580
|
|
|
1
|
|
|
|
|
248
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Module::Starter::Plugin::TT2 - TT2 templates for Module::Starter::Template |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
version 0.125 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Module::Starter qw( |
20
|
|
|
|
|
|
|
Module::Starter::Simple |
21
|
|
|
|
|
|
|
Module::Starter::Plugin::Template |
22
|
|
|
|
|
|
|
Module::Starter::Plugin::TT2 |
23
|
|
|
|
|
|
|
... |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Module::Starter->create_distro( ... ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This Module::Starter plugin is intended to be loaded after |
31
|
|
|
|
|
|
|
Module::Starter::Plugin::Template. It implements the C and C |
32
|
|
|
|
|
|
|
methods, required by the Template plugin. The methods are implemented with |
33
|
|
|
|
|
|
|
Template Toolkit. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This module's distribution includes a directory, C, and a file |
36
|
|
|
|
|
|
|
C that contain stock templates for use with the InlineStore |
37
|
|
|
|
|
|
|
and DirStore plugins. The module itself contains default templates in its data |
38
|
|
|
|
|
|
|
section. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 USAGE |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This module is meant to be used with the template stores in the SimpleStore |
43
|
|
|
|
|
|
|
distribution (although you could certainly write your own template store). If |
44
|
|
|
|
|
|
|
you only want to use the built-in templates, you could have lines like this in |
45
|
|
|
|
|
|
|
your config file (C<~/.module-starter/config>): |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
author: Lord Poncemby |
48
|
|
|
|
|
|
|
email: ponce@peerage.eng |
49
|
|
|
|
|
|
|
plugins: Module::Starter::Simple Module::Starter::Plugin::Template |
50
|
|
|
|
|
|
|
Module::Starter::Plugin::ModuleStore Module::Starter::Plugin::TT2 |
51
|
|
|
|
|
|
|
template_module: Module::Starter::Plugin::TT2 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
(Where the plugins line is one line.) This tells Module::Starter to look for |
54
|
|
|
|
|
|
|
the templates in the data section of Module::Starter::Plugin::TT2, which isn't |
55
|
|
|
|
|
|
|
very interesting, since you'll end up getting the same effect as if you'd just |
56
|
|
|
|
|
|
|
used Module::Starter without plugins. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
To override this behavior, you'd instruct Module::Starter to look somewhere |
59
|
|
|
|
|
|
|
else, either by changing the C setting, changing the |
60
|
|
|
|
|
|
|
MODULE_TEMPLATE_MODULE environment variable, or using a different template |
61
|
|
|
|
|
|
|
store altogether (q.v., SimpleStore or other plugins). |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 C<< renderer >> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
As implemented, this method just creates a new Template Toolkit engine and |
68
|
|
|
|
|
|
|
stores it in the Module::Starter object. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub renderer { |
73
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
74
|
0
|
|
0
|
|
|
|
my $conf = (eval $self->{template_parms})||{}; |
75
|
0
|
|
|
|
|
|
my $renderer = Template->new($conf); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 C<< render( $template, \%options ) >> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This method passes the given template contents and options to the TT2 renderer |
81
|
|
|
|
|
|
|
and returns the resulting document. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub render { |
86
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
87
|
0
|
|
|
|
|
|
my $template = shift; |
88
|
0
|
|
|
|
|
|
my $options = shift; |
89
|
0
|
|
|
|
|
|
my $output; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
$options->{self} = $self; |
92
|
0
|
|
|
|
|
|
$options->{year} = $self->_thisyear; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$self->renderer->process(\$template, $options, \$output); |
95
|
0
|
|
|
|
|
|
return $output; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Ricardo SIGNES, C<< >> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Copyright 2004-2006 Ricardo SIGNES, All Rights Reserved. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
107
|
|
|
|
|
|
|
under the same terms as Perl itself. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__DATA__ |