Debian Codegraph @

README

raw
1 NAME
2 Catalyst::View::Mason - Mason View Class
3
4 SYNOPSIS
5 # use the helper
6 script/create.pl view Mason Mason
7
8 # lib/MyApp/View/Mason.pm
9 package MyApp::View::Mason;
10
11 use base 'Catalyst::View::Mason';
12
13 __PACKAGE__->config(use_match => 0);
14
15 1;
16
17 $c->forward('MyApp::View::Mason');
18
19 DESCRIPTION
20 Want to use a Mason component in your views? No problem!
21 Catalyst::View::Mason comes to the rescue.
22
23 EXAMPLE
24 From the Catalyst controller:
25
26 $c->stash->{name} = 'Homer'; # Pass a scalar
27 $c->stash->{extra_info} = {
28 last_name => 'Simpson',
29 children => [qw(Bart Lisa Maggie)]
30 }; # A ref works too
31
32 From the Mason template:
33
34 <%args>
35 $name
36 $extra_info
37 </%args>
38 <p>Your name is <strong><% $name %> <% $extra_info->{last_name} %></strong>
39 <p>Your children are:
40 <ul>
41 % foreach my $child (@{$extra_info->{children}}) {
42 <li><% $child %></li>
43 % }
44 </ul>
45
46 METHODS
47 new($app, \%config)
48 get_component_path
49 Returns the component path from $c->stash->{template} or
50 $c->request->match or $c->action (depending on the use_match setting).
51
52 process
53 Renders the component specified in $c->stash->{template} or
54 $c->request->match or $c->action (depending on the use_match setting) to
55 $c->response->body.
56
57 Note that the component name must be absolute, or is converted to
58 absolute (i.e., a / is added to the beginning if it doesn't start with
59 one).
60
61 Mason global variables $base, $c, and $name are automatically set to the
62 base, context, and name of the app, respectively.
63
64 render($c, $component_path, \%args)
65 Renders the given template and returns output, or a
66 HTML::Mason::Exception object upon error.
67
68 The template variables are set to %$args if $args is a hashref, or
69 $c->stash otherwise.
70
71 config
72 This allows you to to pass additional settings to the
73 HTML::Mason::Interp constructor or to set the options as below:
74
75 "template_extension"
76 This string is appended (if present) to "$c->action" when generating
77 a template path.
78
79 Defaults to an empty string.
80
81 Example: "template_extension => '.html'"
82
83 "always_append_template_extension"
84 Set this to a true value if you want "template_extension" to be
85 appended to the component path even if it was explicitly set.
86
87 Defaults to 0.
88
89 Example: "always_append_template_extension => 1"
90
91 "use_match"
92 Use "$c->request->match" instead of "$c->action" to determine which
93 template to use if "$c->stash->{template}" isn't set. This option is
94 deprecated and exists for backward compatibility only.
95
96 Currently defaults to 0. Old code should set this to 1 to avoid
97 breakage.
98
99 Example: "use_match => 0"
100
101 The default HTML::Mason::Interp config options are as follows:
102
103 "comp_root"
104 "$app->config->root"
105
106 "data_dir"
107 "File::Spec->catdir( File::Spec->tmpdir,
108 sprintf('%s_%d_mason_data_dir', $app, $<) )"
109
110 "allow_globals"
111 "qw/$c $name $base/"
112
113 If you add additional allowed globals those will be appended to the
114 list of default globals.
115
116 SEE ALSO
117 Catalyst, HTML::Mason, "Using Mason from a Standalone Script" in
118 HTML::Mason::Admin
119
120 AUTHORS
121 Andres Kievsky "[email protected]"
122 Sebastian Riedel "[email protected]"
123 Marcus Ramberg
124 Florian Ragwitz "[email protected]"
125 Justin Hunter "[email protected]"
126
127 COPYRIGHT
128 This program is free software, you can redistribute it and/or modify it
129 under the same terms as Perl itself.
130