Mojolicious::Plugin::Mason2Renderer - Mason 2 (aka Mason 2.x) Renderer Plugin.
Version 0.03
## Mojolicious::Lite # example -1- use Mojolicious::Lite; plugin 'mason2_renderer'; get '/' => sub { my $self = shift; $self->render('/index', handler => "mason" ); }; app->start; # template: MOJO_HOME/mason/index.mc <html> <body>Welcome</body> </html> # example -2- use Mojolicious::Lite; plugin 'mason2_renderer' => { preload_regexps => [ '.mc$', '/path/to/comps/to/preload', ... ], interp_params => { comp_root => "/path/to/mason/comps", ... (other parameters to the new() Mason::Interp constructor) }, request_params => { ... (other parameters to the new() Mason::Request constructor) }, }; get '/' => sub { my $self = shift; $self->render('/index', handler => "mason", mytext => "Hello world" ); }; app->start; # template: /path/to/mason/comps/index.mc <%args> $mytext => undef </%args> <html> <body>Welcome : <% $mytext %></body> </html> ## Mojolicious # example -1- package MyApp; use Mojo::Base 'Mojolicious'; sub startup { my $self = shift; $self->plugin('mason2_renderer'); $self->routes->get('/' => sub { my $self = shift; $self->render('/index', handler => "mason" ); } ); } 1; # template: MOJO_HOME/mason/index.mc <html> <body>Welcome</body> </html> # example -2- package MyApp; use Mojo::Base 'Mojolicious'; sub startup { my $self = shift; $self->plugin('mason2_renderer', { preload_regexps => [ '.mc$', '/path/to/comps/to/preload', ... ], interp_params => { comp_root => "/path/to/mason/comps", ... (other parameters to the new() Mason::Interp constructor) }, request_params => { ... (other parameters to the new() Mason::Request constructor) }, } ); $self->routes->get('/' => sub { my $self = shift; $self->render('/index', handler => "mason", mytext => "Hello World" ); } ); } 1; # template: /path/to/mason/comps/index.mc <%args> $mytext => undef </%args> <html> <body> Welcome : <% $mytext %><br/> Mason root_comp is <% $c->app->home %><br/> </body> </html>
Mojolicous::Plugin::Mason2Renderer is a renderer for Mason 2 (aka Mason 2.x) template system.
Mason templates have access to the Mojolicious::Controller object as global $c.
comp_root is set to default "MOJO_HOME/mason"
comp_root
Mojolicious::Plugin::Mason2Renderer inherits all methods from Mojolicious::Plugin and implements the following new ones.
$plugin->register;
Register renderer in Mojolicious application.
Mojolicious, Mojolicious::Plugin, http://mojolicio.us.
Mason 1, HTML::Mason, http://www.masonhq.com.
Mason 2, Mason.
Mason 1 Mojolicious Plugin, Mojolicious::Plugin::Mason1Renderer
Alexandre SIMON, <asimon at cpan.org>
<asimon at cpan.org>
You can find documentation for this module with the perldoc command.
perldoc Mojolicious::Plugin::Mason2Renderer
Bugs and feature requests will be tracked at RT:
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-Plugin-Mason2Renderer bug-mojolicious-plugin-mason2renderer at rt.cpan.org
The latest source code can be browsed and fetched at:
https://github.com/igit/Mojolicious-Plugin-Mason2Renderer git clone git://github.com/igit/Mojolicious-Plugin-Mason2Renderer.git
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mojolicious-Plugin-Mason2Renderer
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Mojolicious-Plugin-Mason2Renderer
CPAN Ratings
http://cpanratings.perl.org/d/Mojolicious-Plugin-Mason2Renderer
Search CPAN
http://search.cpan.org/dist/Mojolicious-Plugin-Mason2Renderer/
Original idea was taken from Graham BARR (http://search.cpan.org/~gbarr/) MojoX::Renderer::Mason module. This module was not longer adapted to Mojolicious new Plugin philosophy.
Many, many thanks to Sebastian RIEDEL for developping Mojolicious and Jonathan SWARTZ for developping HTML::Mason and Mason (2).
Copyright 2011 Alexandre SIMON.
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 Mojolicious::Plugin::Mason2Renderer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Mason2Renderer
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Mason2Renderer
For more information on module installation, please visit the detailed CPAN module installation guide.