NAME
Statocles::Template - A template object to pass around
VERSION
version 0.014
DESCRIPTION
This is the template abstraction layer for Statocles.
ATTRIBUTES
content
The main template string. This will be generated by reading the file path
by default.
path
The path to the file for this template. Optional.
METHODS
BUILDARGS( )
Set the default path to something useful for in-memory templates.
render( %args )
Render this template, passing in %args. Each key in %args will be available as a scalar in the template.
coercion
A class method to returns a coercion sub to convert strings into template objects.
TEMPLATE LANGUAGE
The default Statocles template language is Mojolicious's Embedded Perl template. Inside the template, every key of the %args passed to render() will be available as a simple scalar:
# template.tmpl
% for my $p ( @$pages ) {
<%= $p->{content} %>
% }
my $tmpl = Statocles::Template->new( path => 'template.tmpl' );
$tmpl->render(
pages => [
{ content => 'foo' },
{ content => 'bar' },
]
);
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.