NAME
Catalyst::View::HTML::Mason - HTML::Mason rendering for Catalyst
SYNOPSIS
package MyApp::View::Mason;
use Moose;
use namespace::autoclean;
extends 'Catalyst::View::HTML::Mason';
__PACKAGE__->config(
interp_args => {
comp_root => MyApp->path_to('root'),
},
);
1;
DESCRIPTION
This module provides rendering of HTML::Mason templates for Catalyst applications.
It's basically a rewrite of Catalyst::View::Mason, which became increasingly hard to maintain over time, while keeping backward compatibility.
ATTRIBUTES
interp
The mason interpreter instance responsible for rendering templates.
interp_class
The class the interp
instance is constructed from. Defaults to HTML::Mason::Interp
.
interp_args
Arguments to be passed to the construction of interp
. Defaults to an empty hash reference.
template_extension
File extension to be appended to every component file. By default it's only appended if no explicit component file has been provided in $ctx->stash->{template}
.
always_append_template_extension
If this is set to a true value, template_extension
will also be appended to component paths provided in $ctx->stash->{template}
.
encoding
Encode Mason output with the given encoding. Can be a string encoding name (which will be resolved using Encode::find_encoding()), or an Encode::Encoding object. See Encode::Supported for a list of encodings.
globals
Arrayref of string names to export into each rendered component. Off by default.
Example:
globals => [ '$foo', '%bar' ]
#or
globals => '$baz',
Would export $foo and %bar to every Mason component as globals using identically-named values in the stash, similar to:
our $foo = $c->stash->{foo};
our %bar = %{ $c->stash->{bar} };
To export just the context as $c, one would set globals => '$c' and make sure to set $c->stash->{c} = $c on each request, such as in an auto
in the root controller.
METHODS
render($ctx, $component, \%args)
Renders the given component and returns its output.
A hash of template variables may be provided in $args
. If $args
isn't given, template variables will be taken from $ctx->stash
.
A NOTE ABOUT DHANDLERS
Note that this view does not support automatic dispatching to Mason dhandlers. Dhandlers can still be used, but they must be referred to explicitly like any other component.
AUTHORS
Florian Ragwitz <rafl@debian.org>
Sebastian Willert <willert@cpan.org>
Robert Buels <rbuels@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Florian Ragwitz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.