.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Mason::Manual::UpgradingFromMason1 3pm" .TH Mason::Manual::UpgradingFromMason1 3pm "2014-02-01" "perl v5.18.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mason::Manual::UpgradingFromMason1 \- Summary of differences between Mason 1 and Mason 2 .SH "DESCRIPTION" .IX Header "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. .PP That said, the philosophy and core syntax are similar enough that it should still be recognizable and \*(L"feel like Mason\*(R" to existing users. .PP 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. .PP There is currently no automated way to convert a Mason 1 to a Mason 2 site, but there hopefully will be someday. (Contributions welcome. :)) .SH "ARCHITECTURE" .IX Header "ARCHITECTURE" .IP "\(bu" 4 In Mason 1, each component was an instance of a common Component class. In Mason 2, each component is its \fIown\fR Moose class, with a class name generated from the component path. .IP "\(bu" 4 The main component body \- the content and the inline Perl sections \- are placed into a \f(CW\*(C`main\*(C'\fR method. .IP "\(bu" 4 Calling a component (via \f(CW\*(C`<& &>\*(C'\fR or \f(CW\*(C`$m\->comp\*(C'\fR ) entails creating a new instance of the component class, and calling its \f(CW\*(C`main\*(C'\fR method. Component call parameters are passed to the constructor and placed in attributes. .SH "MAJOR FEATURES" .IX Header "MAJOR FEATURES" .IP "\(bu" 4 \&\fBPlugins\fR 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. .IP "\(bu" 4 \&\fBWeb integration\fR 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 \s-1PSGI\s0 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. .IP "\(bu" 4 \&\fBSubcomponents\fR have been eliminated, replaced with class methods. .IP "\(bu" 4 \&\fBError processing/formatting\fR 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. .IP "\(bu" 4 \&\fBResolvers\fR and \fBAnonymous components\fR have been eliminated. Components need to be in files. If your components live in another data source, you could use \&\s-1FUSE\s0 or a custom plugin to keep a file hierarchy up to date with the data source. .IP "\(bu" 4 \&\fBCaching\fR support has been simplified. \f(CW\*(C`$m\->cache\*(C'\fR simply returns a \&\s-1CHI\s0 object with an appropriate namespace for the component. .SH "SYNTAX" .IX Header "SYNTAX" .IP "\(bu" 4 \&\f(CW\*(C`<%once>\*(C'\fR has been replaced with \f(CW\*(C`<%class>\*(C'\fR. .IP "\(bu" 4 \&\f(CW\*(C`<%cleanup>\*(C'\fR 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 \f(CW\*(C`DEMOLISH\*(C'\fR method to the component. .IP "\(bu" 4 Single blank lines between blocks are now removed, so you can space blocks out for readability without generating a ton of newlines. .IP "\(bu" 4 Whitespace is required after a %\-line and around the expression in a \f(CW\*(C`<% %>\*(C'\fR tag. This improves readability and leaves open the possibility of additional syntax. .IP "\(bu" 4 \&\f(CW\*(C`<%args>\*(C'\fR and \f(CW\*(C`<%shared>\*(C'\fR are gone. Use Moose attributes instead. .IP "\(bu" 4 The \f(CW\*(C`<%ARGS>\*(C'\fR hash is gone, you can instead use \f(CW\*(C`$.args\*(C'\fR or \f(CW\*(C`$self\->args\*(C'\fR to get all the parameters passed to a component. .IP "\(bu" 4 \&\f(CW\*(C`<%method>\*(C'\fR and \f(CW\*(C`<%def>\*(C'\fR have been replaced with just \f(CW\*(C`<%method>\*(C'\fR, which creates a true class method rather than a subcomponent. .IP "\(bu" 4 The \f(CW\*(C`<%filter>\*(C'\fR tag is now used to define filters, instead of automatically applying a filter to the current component. .IP "\(bu" 4 \&\f(CW\*(C`Components with content\*(C'\fR syntax has been eliminated; use the CompCall filter instead. .IP "\(bu" 4 \&\f(CW\*(C`Escape flags\*(C'\fR in substitution tags now utilize filters. .SH "MISC PARAMETER CHANGES" .IX Header "MISC PARAMETER CHANGES" .SS "Interp parameters" .IX Subsection "Interp parameters" .IP "\(bu" 4 \&\f(CW\*(C`buffer_preallocate_size\*(C'\fR, \f(CW\*(C`code_cache_max_size\*(C'\fR and \f(CW\*(C`use_object_files\*(C'\fR have been deemed unnecessary and eliminated. .IP "\(bu" 4 \&\f(CW\*(C`escape_flags\*(C'\fR has been eliminated; define filters instead. .IP "\(bu" 4 \&\f(CW\*(C`data_dir\*(C'\fR now defaults to a directory created with tempdir. .IP "\(bu" 4 \&\f(CW\*(C`preloads\*(C'\fR has been eliminated; this code does roughly the same: .Sp .Vb 1 \& $interp\->load($_) for (grep { /some_condition/ } $interp\->all_paths); .Ve .SS "Request parameters" .IX Subsection "Request parameters" .IP "\(bu" 4 \&\f(CW\*(C`autoflush\*(C'\fR and \f(CW\*(C`max_recurse\*(C'\fR have been eliminated because they are too difficult to implement efficiently. .SS "Compiler parameters" .IX Subsection "Compiler parameters" .IP "\(bu" 4 \&\f(CW\*(C`preprocess\*(C'\fR, \f(CW\*(C`postprocess_perl\*(C'\fR, and \f(CW\*(C`postprocess_text\*(C'\fR have been eliminated; similar effects can be achieved with plugins targeting Mason::Compilation. .IP "\(bu" 4 \&\f(CW\*(C`default_escape_flags\*(C'\fR has been eliminated, but see Mason::Plugin::DefaultFilter for a third-party substitute. .SH "MISC METHOD CHANGES" .IX Header "MISC METHOD CHANGES" .SS "Interp methods" .IX Subsection "Interp methods" .IP "\(bu" 4 \&\f(CW\*(C`exec\*(C'\fR has been renamed to run. .SS "Request methods" .IX Subsection "Request methods" .IP "\(bu" 4 \&\f(CW\*(C`cache_self\*(C'\fR has been eliminated; use the Cache filter instead. .IP "\(bu" 4 \&\f(CW\*(C`callers\*(C'\fR, \f(CW\*(C`caller\*(C'\fR and \f(CW\*(C`caller_args\*(C'\fR have been eliminated; now that component calls are simply method calls underneath, they are too difficult to implement efficiently. .IP "\(bu" 4 \&\f(CW\*(C`call_next\*(C'\fR has been replaced with Moose's \f(CW\*(C`inner\*(C'\fR. .IP "\(bu" 4 \&\f(CW\*(C`call_self\*(C'\fR has been eliminated; use filters instead. .IP "\(bu" 4 \&\f(CW\*(C`current_comp\*(C'\fR has been eliminated. Within a component, use \f(CW$self\fR; outside a component you can call current_comp_class, which will at least get you the class. .IP "\(bu" 4 \&\f(CW\*(C`dhandler_arg\*(C'\fR has been renamed to path_info. .IP "\(bu" 4 \&\f(CW\*(C`exec\*(C'\fR has been renamed to run. .IP "\(bu" 4 \&\f(CW\*(C`fetch_comp\*(C'\fR has been renamed to load. .IP "\(bu" 4 \&\f(CW\*(C`subexec\*(C'\fR has been replaced with visit and go. .SH "SEE ALSO" .IX Header "SEE ALSO" Mason .SH "AUTHOR" .IX Header "AUTHOR" Jonathan Swartz .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2012 by Jonathan Swartz. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.