NAME
Leyland::View - Leyland view base class
VERSION
version 1.000001
SYNOPSIS
# if you're planning on creating a new Leyland view class,
# then do something like this:
package Leyland::View::SomeEngine;
use Moo;
use namespace::clean;
use SomeEngine;
with 'Leyland::View';
has 'engine' => (is => 'ro', default => sub { SomeEngine->new });
sub render {
my ($self, $view, $context, $use_layout) = @_;
$use_layout = 1 unless defined $use_layout;
return $self->engine->render($view, $context, $use_layout);
}
1;
DESCRIPTION
This Moo role describes how Leyland view classes - mostly used to render HTML responses (but can be used for pretty much anything) - are to be built. A view class uses a template engine (such as Template::Toolkit or <Tenjin>) to render responses.
Leyland's default view class is Leyland::View::Tenjin, which uses the Tenjin template engine.
REQUIRED METHODS
Consuming classes are required to implement the following methods:
render( $view_name, [ \%context, $use_layout ] )
This method receives the name of a view (or "template" if you will, such as 'index.html' or 'resource.json'), and a hash-ref of variables to be available for the template (known as the "context"). Leyland will automatically include 'c' for the request's context object (most probably a Leyland::Context object) and 'l' for the application object. $use_layout
, if provided, will be a boolean value indicating whether the view should be rendered inside a layout view (not relevant for every template engine). Expected to be true by default.
Returns the rendered output.
PROVIDED ATTRIBUTES
view_dir
The directory in which views/templates reside. By default, this will be 'views' (relative to the current working directory).
AUTHOR
Ido Perlmuter, <ido at ido50.net>
BUGS
Please report any bugs or feature requests to bug-Leyland at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Leyland. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Leyland::View
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
Copyright 2010-2014 Ido Perlmuter.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.