Perlanet::Trait::TemplateToolkit - render the feed via a Template Toolkit


Perlanet documentation Contained in the Perlanet distribution.

Index


Code Index:

NAME

Top

Perlanet::Trait::TemplateToolkit - render the feed via a Template Toolkit template

SYNOPSIS

Top

   my $perlanet = Perlanet->new_with_traits(
     traits => [ 'Perlanet::Trait::TemplateToolkit' ]
   );

   $perlanet->run;

DESCRIPTION

Top

Renders the aggregated set of feeds via a Template Toolkit template.

ATTRIBUTES

Top

template_input

The Template Toolkit template to use as input

template_output

The path to save the resulting output to

TEMPLATE TOOLKIT STASH

Top

The following are exported into your template:

feed

A Perlanet::Feed that represents the aggregation of all posts

AUTHOR

Top

Oliver Charles, <oliver.g.charles@googlemail.com>

COPYRIGHT AND LICENSE

Top


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;