Plack::Middleware::FileWrap - Wrap file with headers/footers in Plack
version 0.01
use Plack::Builder; # with text mount '/static/docs/' => builder { enable 'FileWrap', headers => [\'TEST HEAD'], footers => [\'TEST FOOT']; Plack::App::File->new( root => "/path/to/static/docs" )->to_app; }, # with file builder { enable 'FileWrap', headers => ['/path/to/headerA.html', '/path/to/headerB.html'], footers => ['/path/to/footer.html']; $app; },
Enable this middleware to allow your Plack-based application to have common header/footer.
Arrayref. Text ref or file paths. can be mixed like
headers => [ \'<!-- blabla -->', '/path/to/file/header.html' ]
If you have images or other files under the same directory and you don't want to apply the changes, please use enable_if:
mount '/static/docs/' => builder { enable_if { $_[0]->{PATH_INFO} =~ /\.html/ } 'FileWrap', headers => ["$root/static/docs/header.html"], footers => ["$root/static/docs/footer.html"]; Plack::App::File->new( root => "$root/static/docs" )->to_app; },
Fayland Lam <fayland@gmail.com>
This software is copyright (c) 2011 by Fayland Lam.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Plack::Middleware::FileWrap, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::FileWrap
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::FileWrap
For more information on module installation, please visit the detailed CPAN module installation guide.