Catalyst::View::MicroTemplate::DataSection - Text::MicroTemplate::DataSection View For Catalyst
# subclassing to making your view class package MyApp::View::DataSection; use Moose; extends 'Catalyst::View::MicroTemplate::DataSection'; 1; # using in a controller sub index :Path :Args(0) { my ( $self, $c ) = @_; $c->stash->{username} = 'masakyst'; } ... .. __PACKAGE__->meta->make_immutable; 1; __DATA__ @@ index.mt ? my $stash = shift; hello <?= $stash->{username} ?> !!
Catalyst::View::MicroTemplate::DataSection is simple wrapper module allows you to render MicroTemplate template from __DATA__ section in Catalyst controller.
plackup -a hello.psgi
package Hello::View::MicroTemplate::DataSection { use Moose; extends 'Catalyst::View::MicroTemplate::DataSection'; sub _build_section { 'main' } }; package Hello::Controller::Root { use Moose; BEGIN { extends 'Catalyst::Controller' } __PACKAGE__->config(namespace => ''); sub index :Path :Args(0) { my ($self, $c) = @_; $c->stash->{okinawa} = "Yomitan perl mongers"; } sub end : ActionClass('RenderView') {} }; package Hello 0.01 { use Moose; use Catalyst::Runtime 5.80; extends 'Catalyst'; __PACKAGE__->setup(); }; package main; Hello->psgi_app; __DATA__ @@ index.mt ? my $stash = shift; <?= $stash->{okinawa} ?>
Copyright (C) Masaaki Saito.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Masaaki Saito <masakyst.public@gmail.com>
To install Catalyst::View::MicroTemplate::DataSection, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::View::MicroTemplate::DataSection
CPAN shell
perl -MCPAN -e shell install Catalyst::View::MicroTemplate::DataSection
For more information on module installation, please visit the detailed CPAN module installation guide.