SlideShare une entreprise Scribd logo
1  sur  12
Mason 2
True OO templating for Perl
         Jonathan Swartz
            July 26, 2011
     Seattle Perl Users Group
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 &>
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
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
Why Mason 2?
• New technologies
 • Moose
 • Plack/PSGI
• Long-desired syntax and features
• Long-standing annoyances
• Changes in how people use Mason today
Mason 1 vs 2
   It’s called...      HTML::Mason              Mason

Components 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
Components as Moose Classes

      arguments    -->   attributes
    autohandlers   -->   parent classes
   “inheritance”   -->   inheritance
 subcomponents     -->   methods
common package     -->   distinct package
anon subroutines   -->   named subroutines
               Plus the power of Moose
               (roles, method modifiers, ...)
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...)
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
Standard file extensions

• .mc - top-level component
• .mi - internal component
• .mp - pure-perl component
Demo
More information

• http://search.cpan.org/perldoc?Mason
• http://www.openswartz.com/

Contenu connexe

Similaire à Mason 2 - July 2011 - Seattle Perl Users Group

EoinWoods_WhereDidMyArchitectureGoPreservingSoftwareArchitectureInItsImplemen...
EoinWoods_WhereDidMyArchitectureGoPreservingSoftwareArchitectureInItsImplemen...EoinWoods_WhereDidMyArchitectureGoPreservingSoftwareArchitectureInItsImplemen...
EoinWoods_WhereDidMyArchitectureGoPreservingSoftwareArchitectureInItsImplemen...
Kostas Mavridis
 
2012.10 - DDI Lifecycle - Moving Forward - 3
2012.10 - DDI Lifecycle - Moving Forward - 32012.10 - DDI Lifecycle - Moving Forward - 3
2012.10 - DDI Lifecycle - Moving Forward - 3
Dr.-Ing. Thomas Hartmann
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module development
Ivan Chepurnyi
 

Similaire à Mason 2 - July 2011 - Seattle Perl Users Group (20)

Zotonic presentation Erlang Camp Boston, august 2011
Zotonic presentation Erlang Camp Boston, august 2011Zotonic presentation Erlang Camp Boston, august 2011
Zotonic presentation Erlang Camp Boston, august 2011
 
EoinWoods_WhereDidMyArchitectureGoPreservingSoftwareArchitectureInItsImplemen...
EoinWoods_WhereDidMyArchitectureGoPreservingSoftwareArchitectureInItsImplemen...EoinWoods_WhereDidMyArchitectureGoPreservingSoftwareArchitectureInItsImplemen...
EoinWoods_WhereDidMyArchitectureGoPreservingSoftwareArchitectureInItsImplemen...
 
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...
 
A Workhorse Named Mule
A Workhorse Named MuleA Workhorse Named Mule
A Workhorse Named Mule
 
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic ApproachLiving with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
 
SophiaConf2010 Présentation des Retours d'expériences de la Conférence du 08 ...
SophiaConf2010 Présentation des Retours d'expériences de la Conférence du 08 ...SophiaConf2010 Présentation des Retours d'expériences de la Conférence du 08 ...
SophiaConf2010 Présentation des Retours d'expériences de la Conférence du 08 ...
 
Enterprise service bus part 2
Enterprise service bus part 2Enterprise service bus part 2
Enterprise service bus part 2
 
Essential Camel Components
Essential Camel ComponentsEssential Camel Components
Essential Camel Components
 
Magento 2 View Layer Evolution
Magento 2 View Layer EvolutionMagento 2 View Layer Evolution
Magento 2 View Layer Evolution
 
2012.10 - DDI Lifecycle - Moving Forward - 3
2012.10 - DDI Lifecycle - Moving Forward - 32012.10 - DDI Lifecycle - Moving Forward - 3
2012.10 - DDI Lifecycle - Moving Forward - 3
 
Drupal for Webmasters by Brett Baker
Drupal for Webmasters by Brett BakerDrupal for Webmasters by Brett Baker
Drupal for Webmasters by Brett Baker
 
The CoFX Data Model
The CoFX Data ModelThe CoFX Data Model
The CoFX Data Model
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module development
 
Puppet
PuppetPuppet
Puppet
 
The Web Scale
The Web ScaleThe Web Scale
The Web Scale
 
Bespoke service discovery with HAProxy and Marathon on Mesos
Bespoke service discovery with HAProxy and Marathon on MesosBespoke service discovery with HAProxy and Marathon on Mesos
Bespoke service discovery with HAProxy and Marathon on Mesos
 
Flamingo Carotene
Flamingo CaroteneFlamingo Carotene
Flamingo Carotene
 
01 Metasploit kung fu introduction
01 Metasploit kung fu introduction01 Metasploit kung fu introduction
01 Metasploit kung fu introduction
 
The way from DB-driven development to DDD
The way from DB-driven development to DDDThe way from DB-driven development to DDD
The way from DB-driven development to DDD
 
Scalable java script applications
Scalable java script applicationsScalable java script applications
Scalable java script applications
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Mason 2 - July 2011 - Seattle Perl Users Group

  • 1. Mason 2 True 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 Mason Components 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 --> methods common package --> distinct package anon 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

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n