| Perlanet documentation | Contained in the Perlanet distribution. |
Perlanet::Trait::TemplateToolkit - render the feed via a Template Toolkit template
my $perlanet = Perlanet->new_with_traits(
traits => [ 'Perlanet::Trait::TemplateToolkit' ]
);
$perlanet->run;
Renders the aggregated set of feeds via a Template Toolkit template.
The Template Toolkit template to use as input
The path to save the resulting output to
The following are exported into your template:
A Perlanet::Feed that represents the aggregation of all posts
Oliver Charles, <oliver.g.charles@googlemail.com>
Copyright (c) 2010 by Magnum Solutions Ltd.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
| Perlanet documentation | Contained in the Perlanet distribution. |
package Perlanet::Trait::TemplateToolkit; use Moose::Role; use namespace::autoclean;
use Template; use Carp; has 'page' => ( isa => 'HashRef', is => 'rw', default => sub { { file => 'index.html', template => 'index.tt' } }, ); after 'render' => sub { my ($self, $feed) = @_; my $tt = Template->new; $tt->process( $self->page->{template}, { feed => $feed, cfg => $self, }, $self->page->{file}, { binmode => ':utf8' } ) or croak $tt->error; };
1;