Perlanet/Trait/TemplateToolkit.pm

filter: Statementstmt 96.0% 24 / 25 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 91.4% 32 / 35 CC 2 SCAR 2.9
CC
2
Cov
93%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.3
« Perlanet/Simple.pm ↑ Summary Perlanet/Trait/Cache.pm »
1 package Perlanet::Trait::TemplateToolkit;
2  
3 11 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Perlanet::Trait::TemplateToolkit - render the feed via a Template Toolkit
13 template
14  
15 =head1 SYNOPSIS
16  
17 my $perlanet = Perlanet->new_with_traits(
18 traits => [ 'Perlanet::Trait::TemplateToolkit' ]
19 );
20  
21 $perlanet->run;
22  
23 =head1 DESCRIPTION
24  
25 Renders the aggregated set of feeds via a Template Toolkit template.
26  
27 =head1 ATTRIBUTES
28  
29 =head2 template_input
30  
31 The Template Toolkit template to use as input
32  
33 =head2 template_output
34  
35 The path to save the resulting output to
36  
37 =head1 TEMPLATE TOOLKIT STASH
38  
39 The following are exported into your template:
40  
41 =head2 feed
42  
43 A L<Perlanet::Feed> that represents the aggregation of all posts
44  
45 =cut
46  
47 11 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 has 'page' => (
50 isa => 'HashRef',
51 is => 'ro',
52 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 0 { file => 'index.html', template => 'index.tt' };
54 },
55 11 );
56  
57 2 ▶after 'render' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
58 2 my $self = shift;
59 2 my ($feed) = @_;
60 2 my $tt = Template->new;
61 $tt->process(
62 $self->page->{template},
63 {
64 feed => $feed,
65 cfg => $self, # deprecated
66 config => $self->config,
67 },
68 $self->page->{file},
69 {
70 2 ▶ binmode => ':utf8'
Branch: 1 branch
BranchTrueFalseTotal
$tt->process($self->page->{"template"}, {"feed", $feed, "cfg", $self, "config", $self->config}, $self->page->{"file"}, {"binmode", ":utf8"}) or die $tt->error, "\n" 2 0 2
71 }
72 ) or die $tt->error, "\n";
73 11 };
74  
75 =head1 AUTHOR
76  
77 Oliver Charles, <oliver.g.charles@googlemail.com>
78  
79 =head1 COPYRIGHT AND LICENSE
80  
81 Copyright (c) 2010 by Magnum Solutions Ltd.
82  
83 This library is free software; you can redistribute it and/or modify
84 it under the same terms as Perl itself, either Perl version 5.10.0 or,
85 at your option, any later version of Perl 5 you may have available.
86  
87 =cut
88  
89 11 1;
« Perlanet/Simple.pm ↑ Summary Perlanet/Trait/Cache.pm »