From bc3ce88fa5ddacfd9fe1bff2c96fa208a5a65166 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 7 Oct 2012 00:35:39 -0500 Subject: docs --- lib/Plack/Middleware/Xslate.pm | 84 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/lib/Plack/Middleware/Xslate.pm b/lib/Plack/Middleware/Xslate.pm index 9e05a05..c520931 100644 --- a/lib/Plack/Middleware/Xslate.pm +++ b/lib/Plack/Middleware/Xslate.pm @@ -1,6 +1,7 @@ package Plack::Middleware::Xslate; use strict; use warnings; +# ABSTRACT: serve static templates with Plack use base 'Plack::Middleware::Static'; @@ -8,6 +9,43 @@ use Plack::Util::Accessor 'xslate_args', 'xslate_vars'; use Text::Xslate; +=head1 SYNOPSIS + + use Plack::Builder; + + builder { + enable "Xslate", + path => qr{^/}, root => 'root/templates/', pass_through => 1; + $app; + }; + +=head1 DESCRIPTION + +This middleware allows you to serve files processed as L +templates. This is useful for serving sites that are essentially static +content, but with a consistent structure (which can be pulled out into a single +template to include, rather than duplicated across every page). + +Configuration for this middleware is identical to L, +with these additional options: + +=over 4 + +=item xslate_args + +A hashref of arguments to pass to the L constructor. Note that +you cannot pass a C argument here - it will be overridden by the C +option. + +=item xslate_vars + +A hashref of data to use when rendering the template. This will be passed to +C<< Text::Xslate->render >> every time a template is rendered. + +=back + +=cut + sub prepare_app { my $self = shift; $self->{file} = Plack::App::File::Xslate->new({ root => $self->root || '.', encoding => $self->encoding, xslate_args => $self->xslate_args, xslate_vars => $self->xslate_vars }); @@ -76,4 +114,50 @@ sub serve_path { return $res; } +=head1 BUGS + +No known bugs. + +Please report any bugs through RT: email +C, or browse to +L. + +=head1 SEE ALSO + +L - Much of this module's API and implementation were taken +from Plack::Request. + +=head1 SUPPORT + +You can find this documentation for this module with the perldoc command. + + perldoc Plack::Middleware::Xslate + +You can also look for information at: + +=over 4 + +=item * AnnoCPAN: Annotated CPAN documentation + +L + +=item * CPAN Ratings + +L + +=item * RT: CPAN's request tracker + +L + +=item * Search CPAN + +L + +=back + +=for Pod::Coverage + prepare_app + +=cut + 1; -- cgit v1.2.3-54-g00ecf