The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Plugin::Mason2Renderer - Mason 2 (aka Mason 2.x) Renderer Plugin.

VERSION

Version 0.03

SYNOPSIS

  ## 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>

DESCRIPTION

Mojolicous::Plugin::Mason2Renderer is a renderer for Mason 2 (aka Mason 2.x) template system.

Mojolicious::Controller object aka. $c

Mason templates have access to the Mojolicious::Controller object as global $c.

Mason comp_root

comp_root is set to default "MOJO_HOME/mason"

METHODS

Mojolicious::Plugin::Mason2Renderer inherits all methods from Mojolicious::Plugin and implements the following new ones.

register

  $plugin->register;

Register renderer in Mojolicious application.

SEE ALSO

Mojolicious, Mojolicious::Plugin, http://mojolicio.us.

Mason 1, HTML::Mason, http://www.masonhq.com.

Mason 2, Mason.

Mason 1 Mojolicious Plugin, Mojolicious::Plugin::Mason1Renderer

AUTHOR

Alexandre SIMON, <asimon at cpan.org>

BUGS and SUPPORT

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:

ACKNOWLEDGEMENTS

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).

LICENSE AND COPYRIGHT

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.