Dancer::Template::Caribou - Template::Caribou wrapper for Dancer
version 1.0.1
# in 'config.yml' template: Caribou engines: Caribou: namespace: MyApp::View layout_namespace: MyApp::View::Layout default_template: inner_page default_layout_template: page # and then in the application get '/' => sub { ...; template 'main' => \%options; };
Dancer::Template::Caribou is an interface for the Template::Caribou template system. Be forewarned, both this module and Template::Caribou itself are alpha-quality software and are still subject to any changes. Caveat Maxima Emptor.
Dancer::Template::Caribou
Template::Caribou
At the base, if you do
get '/' => sub { ... return template 'MyView', \%options; };
the template name (here MyView) will be concatenated with the configured view namespace (which defaults to Dancer::View) to generate the Caribou class name. A Caribou object is created using %options as its arguments, and its default template (defaulting to page) is then rendered. In other words, the last line of the code above becomes equivalent to
%options
page
return Dancer::View::MyView->new( %options )->page;
Layouts, just like templates, are package names. They are expected to be roles that will be composed with the template class.
The name of the entry template to use. In other words, with the configuration given in the SYNOPSIS, the dancer code
return template 'MyThing';
is equivalent to
return MyApp::View::MyThing->page;
Defaults to page.
Entry template to use when a layout is provided. Defaults to page.
The namespace under which the Caribou template classes are. defaults to Dancer::View.
Dancer::View
Template names can be prefixed with a plus sign if you want it to be used as an absolute namespace.
template 'Relative::View'; # -> Dancer::View::Relative::View template '+My::Absolute::View'; # -> My::Absolute::View
The namespace under which the Caribou layout roles are. defaults to the ::Layout sub-namespace under the template namespace.
::Layout
Like template names, layout names can be prefixed with a plus sign for absolute namespaces;
set layout => 'My::Relative'; # -> Dancer::View::Layour::My::Relative set layout => '+My::Absolute'; # -> My::Absolute
Yanick Champoux <yanick@babyl.dyndns.org>
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.
To install Dancer::Template::Caribou, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer::Template::Caribou
CPAN shell
perl -MCPAN -e shell install Dancer::Template::Caribou
For more information on module installation, please visit the detailed CPAN module installation guide.