Mason 2 - July 2011 - Seattle Perl Users Group

  • 2,545 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
2,545
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. Mason 2True OO templating for Perl Jonathan Swartz July 26, 2011 Seattle Perl Users Group
  • 2. What is Mason?Templating system for generating dynamic content(e.g. web pages) <& header.mi &> <ul> % foreach my $article (@articles) { <li> <a href="<% $article->url %>"> <% $article->title %> </a> </li> %} </ul> <& footer.mi &>
  • 3. Mason Timeline• 1998 - HTML::Mason 0.01• 2001 - HTML::Mason 1.0• 2002 - HTML::Mason 1.1, O’Reilly book• - Used by many mod_perl sites• 2006 - Amazon switches to Mason• - The lost years• 2011 - Mason 2.0
  • 4. History: Past 5 years• Mason enters stasis mode• MVC supplants embedded-code• Web frameworks emerge• Catalyst+TT becomes Perl web “standard”• Mason wiki and mail list fills with weeds• Figured I was done... then they drag me back
  • 5. Why Mason 2?• New technologies • Moose • Plack/PSGI• Long-desired syntax and features• Long-standing annoyances• Changes in how people use Mason today
  • 6. Mason 1 vs 2 It’s called... HTML::Mason MasonComponents are... Instances of a class Classes (Moose) Web integration via... mod_perl + glue PSGI Standardized, Filenames are... Arbitrary, unenforced semi-enforced Plugins are... Limited set of hooks Moose roles
  • 7. Components as Moose Classes arguments --> attributes autohandlers --> parent classes “inheritance” --> inheritance subcomponents --> methodscommon package --> distinct packageanon subroutines --> named subroutines Plus the power of Moose (roles, method modifiers, ...)
  • 8. PSGI/Plack• PSGI - Interface spec between Perl web apps and servers (like CGI)• Allows Mason to work from mod_perl, Perl-only server, standalone script...• Plack - Common tools, middleware, servers (debug console, error trace, sessions...)
  • 9. Catalyst/TT vs Mason Separate M Separate M, V, and C Unified V and C Simplified template Perl in templates language Designer friendly Programmer friendly
  • 10. Standard file extensions• .mc - top-level component• .mi - internal component• .mp - pure-perl component
  • 11. Demo
  • 12. More information• http://search.cpan.org/perldoc?Mason• http://www.openswartz.com/