-
-
02 Apr 2017 17:56:28 UTC
- Distribution: Template-Caribou
- Module version: v1.2.1
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (3)
- Testers (407 / 1 / 55)
- Kwalitee
Bus factor: 1- 86.00% Coverage
- License: perl_5
- Perl: v5.20.0
- Activity
24 month- Tools
- Download (37.1KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- Class::Load
- Exporter::Tiny
- List::AllUtils
- Module::Runtime
- Moose::Exporter
- Moose::Role
- Moose::Util
- MooseX::Role::Parameterized
- Path::Tiny
- Ref::Util
- Text::MultiMarkdown
- Tie::Handle
- Try::Tiny
- XML::Writer
- experimental
- overload
- parent
- strict
- warnings
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Template::Caribou::Files - Role to load templates from files
VERSION
version 1.2.1
SYNOPSIS
package MyTemplate; use Template::Caribou; with 'Template::Caribou::Files' => { dirs => [ './my_templates/' ], intro => [ 'use 5.10.0;' ], }; 1;
DESCRIPTION
A Caribou class consuming the
Template::Caribou::Files
role will automatically import all template files (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
then the templates
foo.bou
andbar.bou
will be created.The template files themselves will be eval'ed in the context of the parent class/namespace, and must return a coderef. E.g.,
# file ./foo.bou # should be done in the class declaration, but # can be done here as well use Template::Caribou::Tags::HTML ':all'; # likewise, would be better if added to # as a Template::Caribou::Files's intro use experimental 'signatures'; sub ($self) { div { say 'this is foo'; $self->bar; } }
METHODS
all_template_dirs
Returns a list of all template directories loaded by the class (directories included by parent classes included).
file_intro
Returns the arrayref of the intro lines added to the .bou templates.
ROLE PARAMETERS
dirs
The array ref of directories to scan for templates.
If not provided, it defaults to the directory associated with the template class. For example, for
package MyTemplates::Foo; use Template::Caribou; with 'Template::Caribou::Files'; 1;
located at lib/MyTemplates/Foo.pm, the default directory will be lib/MyTemplates/Foo/.
intro
Arrayref of lines to add at the beginning of all .bou templates.
package MyTemplates::Foo; use Template::Caribou; with 'Template::Caribou::Files' => { intro => [ q{ use 5.10.0; }, q{ use experimental 'signatures'; }, ]; };
AUTHOR
Yanick Champoux <yanick@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 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.
Module Install Instructions
To install Template::Caribou, copy and paste the appropriate command in to your terminal.
cpanm Template::Caribou
perl -MCPAN -e shell install Template::Caribou
For more information on module installation, please visit the detailed CPAN module installation guide.