The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Template::Caribou::Files - Role to load templates from files

VERSION

version 0.2.3

SYNOPSIS

    package MyTemplate;

    use Moose;

    with 'Template::Caribou';
    with 'Template::Caribou::Files' => {
        dirs => [ 'my_templates/' ],
        auto_reload => 1,
    };

    1;

DESCRIPTION

With Template::Caribou::Files, a Caribou class will automatically import all template file (i.e., all files with a .bou extension) under the given directories.

The names of the imported templates will be their path, relative to the imported directories, without their extension. To take the example in the "SYNOPSIS", if the content of my_templates/ is:

    ./foo.bou
    ./bar.bou
    ./baz/frob.bou

then the templates foo.bou, bar.bou and baz/frob will be created.

METHODS

import_template_file( $name => $file )

Imports the content of $file as a template. If $name is not given, it is assumed to be the basename of the file, minus the extension.

Returns the name of the imported template.

ROLE PARAMETERS

dirs

The array ref of directories to scan for templates.

auto_reload

If set to true, the import directories will be rescanned and every file re-imported before every call to render. Useful during development.

Defaults to false.

AUTHOR

Yanick Champoux <yanick@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Yanick Champoux.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.