1Catalyst::View::Mason(3U)ser Contributed Perl DocumentatiCoantalyst::View::Mason(3)
2
3
4

NAME

6       Catalyst::View::Mason - Mason View Class
7

SYNOPSIS

9           # use the helper
10           script/create.pl view Mason Mason
11
12           # lib/MyApp/View/Mason.pm
13           package MyApp::View::Mason;
14
15           use base 'Catalyst::View::Mason';
16
17           __PACKAGE__->config(use_match => 0);
18
19           1;
20
21           $c->forward('MyApp::View::Mason');
22

DESCRIPTION

24       Want to use a Mason component in your views? No problem!
25       Catalyst::View::Mason comes to the rescue.
26

EXAMPLE

28       From the Catalyst controller:
29
30           $c->stash->{name} = 'Homer'; # Pass a scalar
31           $c->stash->{extra_info} = {
32                      last_name => 'Simpson',
33                      children => [qw(Bart Lisa Maggie)]
34           }; # A ref works too
35
36       From the Mason template:
37
38           <%args>
39           $name
40           $extra_info
41           </%args>
42           <p>Your name is <strong><% $name %> <% $extra_info->{last_name} %></strong>
43           <p>Your children are:
44           <ul>
45           % foreach my $child (@{$extra_info->{children}}) {
46           <li><% $child %></li>
47           % }
48           </ul>
49

METHODS

51   new($app, \%config)
52   get_component_path
53       Returns the component path from $c->stash->{template} or
54       $c->request->match or $c->action (depending on the use_match setting).
55
56   process
57       Renders the component specified in $c->stash->{template} or
58       $c->request->match or $c->action (depending on the use_match setting)
59       to $c->response->body.
60
61       Note that the component name must be absolute, or is converted to
62       absolute (i.e., a / is added to the beginning if it doesn't start with
63       one).
64
65       Mason global variables $base, $c, and $name are automatically set to
66       the base, context, and name of the app, respectively.
67
68   render($c, $component_path, \%args)
69       Renders the given template and returns output, or a
70       HTML::Mason::Exception object upon error.
71
72       The template variables are set to %$args if $args is a hashref, or
73       $c->stash otherwise.
74
75       config
76
77       This allows you to to pass additional settings to the
78       HTML::Mason::Interp constructor or to set the options as below:
79
80       "template_extension"
81           This string is appended (if present) to "$c->action" when
82           generating a template path.
83
84           Defaults to an empty string.
85
86           Example: "template_extension => '.html'"
87
88       "always_append_template_extension"
89           Set this to a true value if you want "template_extension" to be
90           appended to the component path even if it was explicitly set.
91
92           Defaults to 0.
93
94           Example: "always_append_template_extension => 1"
95
96       "use_match"
97           Use "$c->request->match" instead of "$c->action" to determine which
98           template to use if "$c->stash->{template}" isn't set. This option
99           is deprecated and exists for backward compatibility only.
100
101           Currently defaults to 0. Old code should set this to 1 to avoid
102           breakage.
103
104           Example: "use_match => 0"
105
106       The default HTML::Mason::Interp config options are as follows:
107
108       "comp_root"
109           "$app->config->root"
110
111       "data_dir"
112           "File::Spec->catdir( File::Spec->tmpdir,
113           sprintf('%s_%d_mason_data_dir', $app, $<) )"
114
115       "allow_globals"
116           "qw/$c $name $base/"
117
118           If you add additional allowed globals those will be appended to the
119           list of default globals.
120

SEE ALSO

122       Catalyst, HTML::Mason, "Using Mason from a Standalone Script" in
123       HTML::Mason::Admin
124

AUTHORS

126       Andres Kievsky "ank@cpan.org"
127       Sebastian Riedel "sri@cpan.org"
128       Marcus Ramberg
129       Florian Ragwitz "rafl@debian.org"
130       Justin Hunter "justin.d.hunter@gmail.com"
131
133       Copyright (c) 2005 - 2009 the Catalyst::View::Mason "AUTHORS" as listed
134       above.
135
136       This program is free software, you can redistribute it and/or modify it
137       under the same terms as Perl itself.
138
139
140
141perl v5.30.1                      2020-01-29          Catalyst::View::Mason(3)
Impressum