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