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

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. :))

main method.<& &> 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.
$m->cache simply returns a CHI object with an appropriate namespace for the component.
<%once> has been replaced with <%class>.<%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.<% %> tag.
This improves readability and leaves open the possibility of additional syntax.<%args> and <%shared> are gone.
Use Moose attributes instead.<%method> and <%def> have been replaced with just <%method>,
which creates a true class method rather than a subcomponent.<%filter> tag is now used to define filters,
instead of automatically applying a filter to the current component.Components with content syntax has been eliminated; use the CompCall filter instead.Escape flags in substitution tags now utilize filters.
buffer_preallocate_size,
code_cache_max_size and use_object_files have been deemed unnecessary and eliminated.escape_flags has been eliminated; define filters instead.data_dir now defaults to a directory created with tempdir.preloads has been eliminated; this code does roughly the same:
$interp->load($_) for (grep { /some_condition/ } $interp->all_paths);
autoflush and max_recurse have been eliminated because they are too difficult to implement efficiently.preprocess, postprocess_perl, and postprocess_text have been eliminated; similar effects can be achieved with plugins targeting Mason::Compilation.default_escape_flags has been eliminated, but see Mason::Plugin::DefaultFilter for a third-party substitute.
exec has been renamed to run.cache_self has been eliminated; use the Cache filter instead.callers, caller and caller_args have been eliminated; now that component calls are simply method calls underneath, they are too difficult to implement efficiently.call_next has been replaced with Moose's inner.call_self has been eliminated; use filters instead.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.dhandler_arg has been renamed to path_info.exec has been renamed to run.fetch_comp has been renamed to load.subexec has been replaced with visit and go.

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.