summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-07 00:35:39 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-07 00:35:39 -0500
commitbc3ce88fa5ddacfd9fe1bff2c96fa208a5a65166 (patch)
treeaab86cf3765496c9adc1855beb3f5b0365a07edf
parentc07012b96ef77d3e93cce0ab1f43a2d9a7e4930e (diff)
downloadplack-middleware-xslate-bc3ce88fa5ddacfd9fe1bff2c96fa208a5a65166.tar.gz
plack-middleware-xslate-bc3ce88fa5ddacfd9fe1bff2c96fa208a5a65166.zip
docs
-rw-r--r--lib/Plack/Middleware/Xslate.pm84
1 files changed, 84 insertions, 0 deletions
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<Text::Xslate>
+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<Plack::Middleware::Static>,
+with these additional options:
+
+=over 4
+
+=item xslate_args
+
+A hashref of arguments to pass to the L<Text::Xslate> constructor. Note that
+you cannot pass a C<path> argument here - it will be overridden by the C<root>
+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<bug-plack-middleware-xslate at rt.cpan.org>, or browse to
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Plack-Middleware-Xslate>.
+
+=head1 SEE ALSO
+
+L<Plack::Request> - 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<http://annocpan.org/dist/Plack-Middleware-Xslate>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/Plack-Middleware-Xslate>
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Plack-Middleware-Xslate>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/Plack-Middleware-Xslate>
+
+=back
+
+=for Pod::Coverage
+ prepare_app
+
+=cut
+
1;