line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perlanet::Trait::TemplateToolkit; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6675
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Moose::Role; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
4761
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Perlanet::Trait::TemplateToolkit - render the feed via a Template Toolkit |
12
|
|
|
|
|
|
|
template |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $perlanet = Perlanet->new_with_traits( |
17
|
|
|
|
|
|
|
traits => [ 'Perlanet::Trait::TemplateToolkit' ] |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$perlanet->run; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Renders the aggregated set of feeds via a Template Toolkit template. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 template_input |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The Template Toolkit template to use as input |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 template_output |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The path to save the resulting output to |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 TEMPLATE TOOLKIT STASH |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The following are exported into your template: |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 feed |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
A L<Perlanet::Feed> that represents the aggregation of all posts |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
1
|
|
66
|
use Template; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
17
|
|
47
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
171
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has 'page' => ( |
50
|
|
|
|
|
|
|
isa => 'HashRef', |
51
|
|
|
|
|
|
|
is => 'rw', |
52
|
|
|
|
|
|
|
default => sub { |
53
|
|
|
|
|
|
|
{ file => 'index.html', template => 'index.tt' } |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
after 'render' => sub { |
58
|
|
|
|
|
|
|
my ($self, $feed) = @_; |
59
|
|
|
|
|
|
|
my $tt = Template->new; |
60
|
|
|
|
|
|
|
$tt->process( |
61
|
|
|
|
|
|
|
$self->page->{template}, |
62
|
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
|
feed => $feed, |
64
|
|
|
|
|
|
|
cfg => $self, |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
$self->page->{file}, |
67
|
|
|
|
|
|
|
{ |
68
|
|
|
|
|
|
|
binmode => ':utf8' |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
) or croak $tt->error; |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Oliver Charles, <oliver.g.charles@googlemail.com> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Copyright (c) 2010 by Magnum Solutions Ltd. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
82
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.10.0 or, |
83
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |