Leyland::View - Leyland view base class
version 0.001007
# if you're planning on creating a new Leyland view class, # then do something like this: package Leyland::View::SomeEngine; use Moose; use namespace::autoclean; use SomeEngine; with 'Leyland::View'; has 'engine' => (is => 'ro', isa => 'SomeEngine', 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); } __PACKAGE__->meta->make_immutable;
This Moose 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, as you may have guesses, uses the Tenjin template engine.
Consuming classes are required to implement the following methods:
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.
$use_layout
Returns the rendered output.
Ido Perlmuter, <ido at ido50.net>
<ido at ido50.net>
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.
bug-Leyland at rt.cpan.org
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
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Leyland
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Leyland
CPAN Ratings
http://cpanratings.perl.org/d/Leyland
Search CPAN
http://search.cpan.org/dist/Leyland/
Copyright 2010-2011 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.
To install Leyland, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Leyland
CPAN shell
perl -MCPAN -e shell install Leyland
For more information on module installation, please visit the detailed CPAN module installation guide.