GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MASON::MANUAL::UPGRADINGFROMMASON1 (3)

.ds Aq ’

NAME

Mason::Manual::UpgradingFromMason1 - Summary of differences between Mason 1 and Mason 2

CONTENTS

DESCRIPTION

Mason 2.x comes ten years after Mason 1.0 (known as HTML::Mason) and twelve years after the original Mason release. It has been rearchitected and reimplemented from the ground up.

That said, the philosophy and core syntax are similar enough that it should still be recognizable and feel like Mason to existing users.

This manual attempts to summarize the differences between Mason 1 and 2, to help existing users decide if they are interested and, if so, migrate their projects.

There is currently no automated way to convert a Mason 1 to a Mason 2 site, but there hopefully will be someday. (Contributions welcome. :))

ARCHITECTURE

o In Mason 1, each component was an instance of a common Component class. In Mason 2, each component is its own Moose class, with a class name generated from the component path.
o The main component body - the content and the inline Perl sections - are placed into a main method.
o Calling a component (via <& &> or $m->comp ) entails creating a new instance of the component class, and calling its main method. Component call parameters are passed to the constructor and placed in attributes.

MAJOR FEATURES

o <B>PluginsB> now utilize Moose roles and are much more powerful and flexible than in Mason 1. Some features that were (or would have been) in the core of Mason 1 are now in plugins. See Mason::Manual::Plugins.
o <B>Web integrationB> in Mason 1 was centered around mod_perl and was part of the core. In Mason 2 all web integration has been split out into a companion web framework, Poet, which in turn uses PSGI to integrate with any server backend. You can also use Mason as the templating layer in popular web frameworks such as Catalyst and Dancer. There is no longer anything web-specific in the Mason core.
o <B>SubcomponentsB> have been eliminated, replaced with class methods.
o <B>Error processing/formattingB> has been eliminated. Mason now simply throws fatal errors to the caller. In a Plack environment, Plack::Middleware::StackTrace will catch the error and format it nicely.
o <B>ResolversB> and <B>Anonymous componentsB> have been eliminated. Components need to be in files. If your components live in another data source, you could use FUSE <http://fuse.sourceforge.net/> or a custom plugin to keep a file hierarchy up to date with the data source.
o <B>CachingB> support has been simplified. $m->cache simply returns a CHI object with an appropriate namespace for the component.

SYNTAX

o <%once> has been replaced with <%class>.
o <%cleanup> has been eliminated; it was not very useful anyway, since it was not guaranteed to run after an exception. You can use add_cleanup to add cleanup code for the end of the request, which is good enough in most cases, or you can add a DEMOLISH method to the component.
o Single blank lines between blocks are now removed, so you can space blocks out for readability without generating a ton of newlines.
o Whitespace is required after a %-line and around the expression in a <% %> tag. This improves readability and leaves open the possibility of additional syntax.
o <%args> and <%shared> are gone. Use Moose attributes instead.
o The <%ARGS> hash is gone, you can instead use $.args or $self->args to get all the parameters passed to a component.
o <%method> and <%def> have been replaced with just <%method>, which creates a true class method rather than a subcomponent.
o The <%filter> tag is now used to define filters, instead of automatically applying a filter to the current component.
o Components with content syntax has been eliminated; use the CompCall filter instead.
o Escape flags in substitution tags now utilize filters.

MISC PARAMETER CHANGES

    Interp parameters

o buffer_preallocate_size, code_cache_max_size and use_object_files have been deemed unnecessary and eliminated.
o escape_flags has been eliminated; define filters instead.
o data_dir now defaults to a directory created with tempdir.
o preloads has been eliminated; this code does roughly the same:



    $interp->load($_) for (grep { /some_condition/ } $interp->all_paths);



    Request parameters

o autoflush and max_recurse have been eliminated because they are too difficult to implement efficiently.

    Compiler parameters

o preprocess, postprocess_perl, and postprocess_text have been eliminated; similar effects can be achieved with plugins targeting Mason::Compilation.
o default_escape_flags has been eliminated, but see Mason::Plugin::DefaultFilter for a third-party substitute.

MISC METHOD CHANGES

    Interp methods

o exec has been renamed to run.

    Request methods

o cache_self has been eliminated; use the Cache filter instead.
o callers, caller and caller_args have been eliminated; now that component calls are simply method calls underneath, they are too difficult to implement efficiently.
o call_next has been replaced with Moose’s inner.
o call_self has been eliminated; use filters instead.
o current_comp has been eliminated. Within a component, use $self; outside a component you can call current_comp_class, which will at least get you the class.
o dhandler_arg has been renamed to path_info.
o exec has been renamed to run.
o fetch_comp has been renamed to load.
o subexec has been replaced with visit and go.

SEE ALSO

Mason

AUTHOR

Jonathan Swartz <swartz@pobox.com>

COPYRIGHT AND LICENSE

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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MASON::MANUAL::UPGRADINGFROMMASON1 (3) 2015-05-16

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.