Catalyst::View::Template::Lace::Renderer - Adapt Template::Lace for Catalyst
TBD
Subclass of Template::Lace:Renderer with some useful, Catalyst specific methods.
This class defines the following public methods
$view->respond($status); $view->respond($status, @headers); $view->respond(@headers);
Used to setup a response. Calling this method will setup an http status, finalize headers and set a body response for the HTML. Content type will be set to 'text/html' automatically. Status is 200 unless you specify otherwise.
Helper method to allow you to wrap or overlay the current view with another view (like a master page view or some other transformation that you prefer to have under the control of the controller). Example:
$c->view('User', name => 'John', age => 42, motto => 'Why Not?') ->overlay_view( 'Master', sub { my $user_dom = shift; # also $_ is localised to this for ease of use title => $_->at('title')->content, css => $_->find('link'), meta => $_->find('meta'), body => $_->at('body')->content}, @more_args_for_MasterView) ->http_ok;
Although you can do this via the template with components there might be cases where you want this under the controller. For example you might use different wrappers based on the logged in user (although again smart use of components could solve that as well; the choice is yours).
Proxy to '$c->detach'
Proxy to '$c->ctx'
We map status codes from HTTP::Status into methods to make sending common request types more simple and more descriptive. The following are the same:
$c->view->respond(200, @args); $c->view->http_ok(@args); do { $c->view->respond(200, @args); $c->detach }; $c->view->http_ok(@args)->detach;
See HTTP::Status for a full list of all the status code helpers.
John Napiorkowski email:jjnapiork@cpan.org
Template::Lace, Catalyst::View::Template::Lace
Copyright 2017, John Napiorkowski email:jjnapiork@cpan.org
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::View::Template::Lace, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::View::Template::Lace
CPAN shell
perl -MCPAN -e shell install Catalyst::View::Template::Lace
For more information on module installation, please visit the detailed CPAN module installation guide.