flowdy has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I am planning the migration from HTML::Mason (version 1) to Mason version 2. It is a website of approx. 1000 pages most of which contain static html only. Mason 1 is very good at wrapping the contents of the files in a frame providing navigation and the usual stuff. Some pages have got additional intelligence that is realized with plain perl.

All pages have got a page title set:

<%ATTR> title => "My humble web page" </%ATTR>

You might ask why it's not simply static <h1>-Tags. But I realized the page title as an attribute due to the fact that this information, among other, is needed for our institutional web management system.

Now, the equivalent Mason 2 code would be:

<%CLASS> has title => (is => "ro", default => "My humble web page", init_arg => + undef); </%CLASS>

'ro' means read-only, init_arg => undef makes sure the title cannot be reset to some 'title' param passed by URL query part. However, I see two problems with this approach:

Is there something I missed in the documentation? Already considered subclassing Mason::Compilation, overwriting its unnamed_block_types to have it cover <%attr>, but then I have not the slightest clue of how to associate any handling code with it, and the code jungle in that module is very impressive, leaves me reluctant to duplicate and change any piece of it.

Unfortunately, CMS are not considered an option for us. Only Mason provides for enough flexibility regarding our needs.

Oh dear monks, I hope you can help me here.

Regards,
flowdy

Replies are listed 'Best First'.
Re: Mason2: Where is support for <%attr> gone? <%class> not a alternative for my need
by Anonymous Monk on Jul 14, 2014 at 20:47 UTC
    Why do you want mason2?

      Thanks for that good a point. The MasonHQ site reads:

      Version 1 of Mason (HTML::Mason) has been around since 1998. It is in wide use and is very stable. However it has not changed much in years and does not use much in the way of Modern Perl.

      Version 2 of Mason (Mason), along with Poet, is being actively developed and has a much more modern architecture. If you are just starting out, we recommend you give Mason 2 a try.

      So, in the course of remaking a webserver, while keeping much of the content, we focussed on Mason 2 in the first place. There are more advantages: Independence from the web server (doesn't depend on modperl, which is obsolete itself and, after all, does not run on Apache 2.4 anyway), automatic tests, to name two. Plus, when a version is actively developed, you can be sure that older versions get more and more neglected (security updates). This can easily be seen since Open Source projects haven't usually much capacity.

      -- flowdy