Mason::Component(3pm) | User Contributed Perl Documentation | Mason::Component(3pm) |
Mason::Component - Mason Component base class
Every Mason component corresponds to a unique class that inherits, directly or indirectly, from this base class.
A new instance of the component class is created whenever a component is called - whether via a top level request, "<& &>" tags, or an << $m->comp >> call. A component instance is only valid for the Mason request in which it was created.
We leave this class as devoid of built-in methods as possible, allowing you to create methods in your own components without worrying about name clashes.
This is the standard call chain for the page component (the initial component of a request).
handle -> render -> wrap -> main
In many cases only "main" will actually do anything.
It should not output any content itself. By default, it simply calls render.
<%augment wrap> <h3>Subtitle section</h3> <div class="main"> <% inner() %> </div> </%augment>
By default, "wrap" simply calls "inner()" to go to the next subclass, and then main at the bottom subclass.
To override a component's parent wrapper, a component can define its own "wrap" using "method" instead of "augment":
<%method wrap> <h3>Parent wrapper will be ignored</h3> <% inner() %> </%method>
To do no wrapping at all, call the component class method "no_wrap":
<%class> CLASS->no_wrap; </%class>
<%class> CLASS->no_wrap; </%class>
<%class> method allow_path_info { 1 } </%class>
my $path = $self->cmeta->path;
Mason
Jonathan Swartz <swartz@pobox.com>
This software is copyright (c) 2012 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2021-01-06 | perl v5.32.0 |