.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Catalyst::View::Mason 3pm"
.TH Catalyst::View::Mason 3pm 2024-03-04 "perl v5.38.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
Catalyst::View::Mason \- Mason View Class
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 2
\& # use the helper
\& script/create.pl view Mason Mason
\&
\& # lib/MyApp/View/Mason.pm
\& package MyApp::View::Mason;
\&
\& use base \*(AqCatalyst::View::Mason\*(Aq;
\&
\& _\|_PACKAGE_\|_\->config(use_match => 0);
\&
\& 1;
\&
\& $c\->forward(\*(AqMyApp::View::Mason\*(Aq);
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
Want to use a Mason component in your views? No problem!
Catalyst::View::Mason comes to the rescue.
.SH EXAMPLE
.IX Header "EXAMPLE"
From the Catalyst controller:
.PP
.Vb 5
\& $c\->stash\->{name} = \*(AqHomer\*(Aq; # Pass a scalar
\& $c\->stash\->{extra_info} = {
\& last_name => \*(AqSimpson\*(Aq,
\& children => [qw(Bart Lisa Maggie)]
\& }; # A ref works too
.Ve
.PP
From the Mason template:
.PP
.Vb 11
\& <%args>
\& $name
\& $extra_info
\& %args>
\&
Your name is <% $name %> <% $extra_info\->{last_name} %>
\&
Your children are:
\&
\& % foreach my $child (@{$extra_info\->{children}}) {
\& - <% $child %>
\& % }
\&
.Ve
.SH METHODS
.IX Header "METHODS"
.SS "new($app, \e%config)"
.IX Subsection "new($app, %config)"
.SS get_component_path
.IX Subsection "get_component_path"
Returns the component path from \f(CW$c\fR\->stash\->{template} or
\&\f(CW$c\fR\->request\->match or \f(CW$c\fR\->action (depending on the use_match setting).
.SS process
.IX Subsection "process"
Renders the component specified in \f(CW$c\fR\->stash\->{template} or \f(CW$c\fR\->request\->match
or \f(CW$c\fR\->action (depending on the use_match setting) to \f(CW$c\fR\->response\->body.
.PP
Note that the component name must be absolute, or is converted to absolute
(i.e., a / is added to the beginning if it doesn't start with one).
.PP
Mason global variables \f(CW$base\fR, \f(CW$c\fR, and \f(CW$name\fR are automatically
set to the base, context, and name of the app, respectively.
.ie n .SS "render($c, $component_path, \e%args)"
.el .SS "render($c, \f(CW$component_path\fP, \e%args)"
.IX Subsection "render($c, $component_path, %args)"
Renders the given template and returns output, or a HTML::Mason::Exception
object upon error.
.PP
The template variables are set to %$args if \f(CW$args\fR is a hashref, or
\&\f(CW$c\fR\->stash otherwise.
.PP
\fIconfig\fR
.IX Subsection "config"
.PP
This allows you to to pass additional settings to the HTML::Mason::Interp
constructor or to set the options as below:
.ie n .IP """template_extension""" 4
.el .IP \f(CWtemplate_extension\fR 4
.IX Item "template_extension"
This string is appended (if present) to \f(CW\*(C`$c\->action\*(C'\fR when generating a
template path.
.Sp
Defaults to an empty string.
.Sp
Example: \f(CW\*(C`template_extension => \*(Aq.html\*(Aq\*(C'\fR
.ie n .IP """always_append_template_extension""" 4
.el .IP \f(CWalways_append_template_extension\fR 4
.IX Item "always_append_template_extension"
Set this to a true value if you want \f(CW\*(C`template_extension\*(C'\fR to be appended to
the component path even if it was explicitly set.
.Sp
Defaults to 0.
.Sp
Example: \f(CW\*(C`always_append_template_extension => 1\*(C'\fR
.ie n .IP """use_match""" 4
.el .IP \f(CWuse_match\fR 4
.IX Item "use_match"
Use \f(CW\*(C`$c\->request\->match\*(C'\fR instead of \f(CW\*(C`$c\->action\*(C'\fR to determine
which template to use if \f(CW\*(C`$c\->stash\->{template}\*(C'\fR isn't set. This option
is deprecated and exists for backward compatibility only.
.Sp
Currently defaults to 0. Old code should set this to 1 to avoid breakage.
.Sp
Example: \f(CW\*(C`use_match => 0\*(C'\fR
.PP
The default HTML::Mason::Interp config options are as follows:
.ie n .IP """comp_root""" 4
.el .IP \f(CWcomp_root\fR 4
.IX Item "comp_root"
\&\f(CW\*(C`$app\->config\->root\*(C'\fR
.ie n .IP """data_dir""" 4
.el .IP \f(CWdata_dir\fR 4
.IX Item "data_dir"
\&\f(CW\*(C`File::Spec\->catdir( File::Spec\->tmpdir, sprintf(\*(Aq%s_%d_mason_data_dir\*(Aq, $app, $<) )\*(C'\fR
.ie n .IP """allow_globals""" 4
.el .IP \f(CWallow_globals\fR 4
.IX Item "allow_globals"
\&\f(CW\*(C`qw/$c $name $base/\*(C'\fR
.Sp
If you add additional allowed globals those will be appended to the list of
default globals.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Catalyst, HTML::Mason, "Using Mason from a Standalone Script" in HTML::Mason::Admin
.SH AUTHORS
.IX Header "AUTHORS"
.ie n .IP "Andres Kievsky ""ank@cpan.org""" 4
.el .IP "Andres Kievsky \f(CWank@cpan.org\fR" 4
.IX Item "Andres Kievsky ank@cpan.org"
.PD 0
.ie n .IP "Sebastian Riedel ""sri@cpan.org""" 4
.el .IP "Sebastian Riedel \f(CWsri@cpan.org\fR" 4
.IX Item "Sebastian Riedel sri@cpan.org"
.IP "Marcus Ramberg" 4
.IX Item "Marcus Ramberg"
.ie n .IP "Florian Ragwitz ""rafl@debian.org""" 4
.el .IP "Florian Ragwitz \f(CWrafl@debian.org\fR" 4
.IX Item "Florian Ragwitz rafl@debian.org"
.ie n .IP "Justin Hunter ""justin.d.hunter@gmail.com""" 4
.el .IP "Justin Hunter \f(CWjustin.d.hunter@gmail.com\fR" 4
.IX Item "Justin Hunter justin.d.hunter@gmail.com"
.PD
.SH COPYRIGHT
.IX Header "COPYRIGHT"
Copyright (c) 2005 \- 2009
the Catalyst::View::Mason "AUTHORS"
as listed above.
.PP
This program is free software, you can redistribute it and/or modify it under
the same terms as Perl itself.