Mason

 view release on metacpan or  search on metacpan

lib/Mason/Compilation.pm  view on Meta::CPAN


Perl code to be added at the bottom of the class. Empty by default.

=item output_class_header ()

Perl code to be added at the top of the class, just after initialization of
Moose, C<$m> and other required pieces. By default it consults the
L<class_header parameter|Mason::Interp/class_header>.

    # Add to the top of every component class:
    #   use Modern::Perl;
    #   use JSON::XS qw(encode_json decode_json);
    #
    override 'output_class_header' => sub {
        return join( "\n",
            super(),
            'use Modern::Perl;',
            'use JSON::XS qw(encode_json decode_json);' );
    };

=item process_perl_code ($coderef)

This method is called on each distinct piece of Perl code in the component.
I<$coderef> is a reference to a string containing the code; the method can
modify the code as desired. See L<Mason::Plugin::DollarDot> for a sample usage.

=item unnamed_block_types ()

lib/Mason/Interp.pm  view on Meta::CPAN

(by default ".mp" and ".mc") to the request path when searching for a matching
page component. Defaults to true.

=item class_header

Perl code to be added at the top of the compiled class for every component,
e.g. to bring in common features or import common methods. Default is the empty
string.

    # Add to the top of every component class:
    #   use Modern::Perl;
    #   use JSON::XS qw(encode_json decode_json);
    #
    my $mason = Mason->new(
        ...
        class_header => qq(
            use Modern::Perl;
            use JSON::XS qw(encode_json decode_json);
        ),
    );

This is used by
L<Mason::Compilation::output_class_header|Mason::Compilation/output_class_header>.
For more advanced usage you can override that method in a subclass or plugin.

=item comp_root



( run in 0.256 second using v1.01-cache-2.11-cpan-4d50c553e7e )