package Bryar::Renderer::TT;
use 5.006;
use strict;
use warnings;
use Carp;
use Template;
use Template::Provider::Encoding;
our $VERSION = '1.2';
=head1 NAME
Bryar::Renderer::TT - Render a blog page with Template Toolkit
=head1 SYNOPSIS
my ($content_type, $output) = $self->generate_html(...);
=head1 DESCRIPTION
This takes a Bryar blog, and the documents selected by the
C
$errorEOF ); } return $output; } our %formats; =head2 register_format $class->register_format($format, $filename, $content_type); Registers a new format that Bryar is capable of producing. This can be used both for spitting out RSS/RDF/ATOM/whatever and for skinning the blog with alternate templates. =cut sub register_format { my ($self, $format, $filename, $content_type) = @_; $formats{$format} = [$filename, $content_type]; } # display formats __PACKAGE__->register_format( html => "template.html", "text/html" ); # TODO: put formats in a formats/ folder by default, but add a config option # for their location. # syndication formats (full posts) __PACKAGE__->register_format( atom => "template.atom", "application/atom+xml" ); # "application/atom+xml" ); __PACKAGE__->register_format( xml => "template.rss", "application/rdf+xml"); __PACKAGE__->register_format( rss => "template.rss", "application/rdf+xml"); __PACKAGE__->register_format( rdf => "template.rss", "application/rdf+xml"); __PACKAGE__->register_format( rss2 => "template.rss2", "application/rss+xml"); # syndication formats (excerpted posts) __PACKAGE__->register_format( atomexcerpt => "template.atomexcerpt", "application/atom+xml" ); __PACKAGE__->register_format( xmlexcerpt => "template.rssexcerpt", "application/rdf+xml"); __PACKAGE__->register_format( rssexcerpt => "template.rssexcerpt", "application/rdf+xml"); __PACKAGE__->register_format( rdfexcerpt => "template.rssexcerpt", "application/rdf+xml"); __PACKAGE__->register_format( rss2excerpt => "template.rss2excerpt", "application/rss+xml"); sub generate { my $class = shift; my $format = shift; $_[0]->config->frontend->report_error("Unknown format", "Can't output a blog in format '$format', don't know what it is.") if !exists $formats{$format}; my ($file, $ct) = @{$formats{$format}}; return ($ct, $class->_tt_process($file, @_)); } =head1 LICENSE This module is free software, and may be distributed under the same terms as Perl itself. =head1 AUTHOR Copyright (C) 2003, Simon Cozens C