Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 88 lines (58 sloc) 1.56 kB
0240368 Split more things up into traits. Improved some docs too
Oliver Charles authored
1 package Perlanet::Trait::TemplateToolkit;
9fa41a6 @davorg Added 'use strict' and 'use warnings' to all modules.
authored
2
3 use strict;
4 use warnings;
5
0240368 Split more things up into traits. Improved some docs too
Oliver Charles authored
6 use Moose::Role;
7 use namespace::autoclean;
8
02e0432 100% POD coverage
Oliver Charles authored
9 =head1 NAME
10
307c9fc @davorg Minor reformatting.
authored
11 Perlanet::Trait::TemplateToolkit - render the feed via a Template Toolkit
12 template
02e0432 100% POD coverage
Oliver Charles authored
13
14 =head1 SYNOPSIS
15
307c9fc @davorg Minor reformatting.
authored
16 my $perlanet = Perlanet->new_with_traits(
17 traits => [ 'Perlanet::Trait::TemplateToolkit' ]
18 );
19
20 $perlanet->run;
02e0432 100% POD coverage
Oliver Charles authored
21
22 =head1 DESCRIPTION
23
307c9fc @davorg Minor reformatting.
authored
24 Renders the aggregated set of feeds via a Template Toolkit template.
02e0432 100% POD coverage
Oliver Charles authored
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
307c9fc @davorg Minor reformatting.
authored
42 A L<Perlanet::Feed> that represents the aggregation of all posts
02e0432 100% POD coverage
Oliver Charles authored
43
44 =cut
45
0240368 Split more things up into traits. Improved some docs too
Oliver Charles authored
46 use Template;
ae2ba53 @mag-sol Attempting to get perlanet comment-line program working again.
mag-sol authored
47 use Carp;
0240368 Split more things up into traits. Improved some docs too
Oliver Charles authored
48
ae2ba53 @mag-sol Attempting to get perlanet comment-line program working again.
mag-sol authored
49 has 'page' => (
307c9fc @davorg Minor reformatting.
authored
50 isa => 'HashRef',
51 is => 'rw',
52 default => sub {
53 { file => 'index.html', template => 'index.tt' }
54 },
0240368 Split more things up into traits. Improved some docs too
Oliver Charles authored
55 );
56
57 after 'render' => sub {
307c9fc @davorg Minor reformatting.
authored
58 my ($self, $feed) = @_;
59 my $tt = Template->new;
60 $tt->process(
61 $self->page->{template},
62 {
63 feed => $feed,
0d22e09 @davorg Pass the whole Perlanet object to the template in a variable called '…
authored
64 cfg => $self,
307c9fc @davorg Minor reformatting.
authored
65 },
66 $self->page->{file},
67 {
68 binmode => ':utf8'
69 }
70 ) or croak $tt->error;
0240368 Split more things up into traits. Improved some docs too
Oliver Charles authored
71 };
72
02e0432 100% POD coverage
Oliver Charles authored
73 =head1 AUTHOR
74
75 Oliver Charles, <oliver.g.charles@googlemail.com>
76
77 =head1 COPYRIGHT AND LICENSE
78
307c9fc @davorg Minor reformatting.
authored
79 Copyright (c) 2010 by Magnum Solutions Ltd.
02e0432 100% POD coverage
Oliver Charles authored
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
0240368 Split more things up into traits. Improved some docs too
Oliver Charles authored
87 1;
Something went wrong with that request. Please try again.