Your SlideShare is downloading. ×
0
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Choosing a Templating System
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Choosing a Templating System

4,899

Published on

I gave this talk at OSCON 2001. The information here is somewhat outdated, but the related article has been updated since …

I gave this talk at OSCON 2001. The information here is somewhat outdated, but the related article has been updated since then:
http://perl.apache.org/docs/tutorials/tmpl/comparison/comparison.html

For the record, this was a really fun talk to give. The title slide had animated flames burning on the screen when people walked in.

Published in: Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
4,899
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
1
Likes
1
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

Transcript

  • 1. Perrin Harkins                                                                                                                   
  • 2. The Ultimate Templating System <ul><li>$HTML =~ s/$(w+)/${$1}/g; </li></ul>FOR MORE INFO... Contact Harkins Enterprises for licensing information. Excellent per-CPU pricing available.
  • 3. Why bother? <ul><li>Consistency of appearance </li></ul><ul><li>Reusability </li></ul><ul><li>Better isolation from changes </li></ul><ul><li>Division of labor </li></ul>
  • 4. Template Taxonomy <ul><li>Execution model </li></ul><ul><li>Language </li></ul><ul><li>Parsing </li></ul><ul><li>Framework or just templates </li></ul>
  • 5. Execution Model <ul><li>Callback </li></ul><ul><ul><li>Mason, Embperl, Apache::ASP </li></ul></ul>mod_perl Perl space template
  • 6. Execution Model <ul><li>Pipeline </li></ul><ul><ul><li>HTML::Template, Template Toolkit </li></ul></ul>mod_perl Perl space template
  • 7. Callback <ul><li>Pro </li></ul><ul><ul><li>Easy to componentize pages </li></ul></ul><ul><ul><li>Quick to get started with </li></ul></ul><ul><li>Con </li></ul><ul><ul><li>Messy for branching </li></ul></ul>
  • 8. Pipeline <ul><li>Pro </li></ul><ul><ul><li>Handles branching cleanly </li></ul></ul><ul><ul><li>Possible tuning opportunities </li></ul></ul><ul><li>Con </li></ul><ul><ul><li>Slower to get started with </li></ul></ul>
  • 9. Language <ul><li>Burn baby burn </li></ul><ul><ul><li>in-line Perl </li></ul></ul><ul><ul><li>mini-languages </li></ul></ul>
  • 10. In-line Perl sample <ul><li>&lt;% my $product = Product-&gt;load(&apos;sku&apos; =&gt; &apos;bar1234&apos;); %&gt; </li></ul><ul><li>&lt;% if ($product-&gt;isbn) { %&gt; </li></ul><ul><li>It&apos;s a book! </li></ul><ul><li>&lt;% } else { %&gt; </li></ul><ul><li>It&apos;s NOT a book! </li></ul><ul><li>&lt;% } %&gt; </li></ul><ul><li>&lt;% foreach my $item (@{$product-&gt;related}) { %&gt; </li></ul><ul><li>You might also enjoy &lt;% $item-&gt;name %&gt;. </li></ul><ul><li>&lt;% } %&gt; </li></ul>
  • 11. Mini-language sample <ul><li>[% USE product(sku=bar1234) %] </li></ul><ul><li>[% IF product.isbn %] </li></ul><ul><li>It&apos;s a book! </li></ul><ul><li>[% ELSE %] </li></ul><ul><li>It&apos;s NOT a book! </li></ul><ul><li>[% END %] </li></ul><ul><li>[% FOREACH item = product.related %] </li></ul><ul><li>You might also enjoy [% item.name %]. </li></ul><ul><li>[% END %] </li></ul>
  • 12. Parsing <ul><li>Compiled </li></ul><ul><li>Cached parse tree </li></ul><ul><li>Repeated parse </li></ul>template Perl code compiled bytecode
  • 13. Frameworks vs. Just Templates <ul><li>URL mapping </li></ul><ul><li>Session tracking </li></ul><ul><li>Output caching </li></ul><ul><li>Form handling </li></ul><ul><li>Debugging </li></ul><ul><li>Other options </li></ul><ul><ul><li>libservlet, Apache::PageKit, OpenInteract, CGI::Application </li></ul></ul>
  • 14. The Contenders <ul><li>SSI </li></ul><ul><li>HTML::Mason </li></ul><ul><li>HTML::Embperl </li></ul><ul><li>Apache::AxKit </li></ul><ul><li>Apache::ASP </li></ul><ul><li>Text::Template </li></ul><ul><li>Template Toolkit </li></ul><ul><li>HTML::Template </li></ul>
  • 15. SSI <ul><li>Callback </li></ul><ul><li>Mini-language </li></ul><ul><li>Repeated Parse </li></ul><ul><li>#perl </li></ul><ul><li>Apache::SSI for filtering </li></ul>
  • 16. HTML::Mason <ul><li>Callback (mostly) </li></ul><ul><li>In-line Perl </li></ul><ul><li>Compiled </li></ul><ul><li>Publishing roots </li></ul><ul><li>&lt;%init&gt; </li></ul><ul><li>Caching </li></ul><ul><li>Parameter checking </li></ul><ul><li>Debug files </li></ul>
  • 17. Text::Template <ul><li>Callback </li></ul><ul><li>In-line Perl </li></ul><ul><li>Compiled </li></ul><ul><li>Safe </li></ul><ul><li>Includes not included </li></ul><ul><li>Cache it yourself </li></ul>
  • 18. Apache::ASP <ul><li>Callback </li></ul><ul><li>In-line Perl </li></ul><ul><li>Compiled </li></ul><ul><li>Built-in objects </li></ul><ul><li>URL-munging sessions </li></ul><ul><li>XMLSubs, XSLT </li></ul><ul><ul><li>&lt;site:header page=&amp;quot;Page Title&amp;quot; /&gt; </li></ul></ul><ul><li>Sticky widgets </li></ul><ul><li>Compressed output </li></ul><ul><li>No RDBMS session storage built in </li></ul>
  • 19. Apache::AxKit <ul><li>Pipeline (usually) </li></ul><ul><li>Mini-language or in-line Perl </li></ul><ul><li>Compiled </li></ul><ul><li>Stylesheet </li></ul><ul><ul><li>XML::XSLT, XML::Sablotron, XPathScript </li></ul></ul><ul><li>Provider </li></ul><ul><ul><li>XSP, XSP taglibs </li></ul></ul><ul><li>Caching </li></ul><ul><li>Compression </li></ul>
  • 20. HTML::Embperl <ul><li>Callback </li></ul><ul><li>In-line Perl </li></ul><ul><li>Compiled </li></ul><ul><li>Safe </li></ul><ul><li>%fdat, %udat </li></ul><ul><li>HTML support </li></ul><ul><ul><li>TABLE, INPUT, query strings, etc. </li></ul></ul><ul><li>EmbperlObject </li></ul><ul><li>Control structures </li></ul>
  • 21. Template Toolkit <ul><li>Pipeline (sorta) </li></ul><ul><li>Mini-language </li></ul><ul><li>Compiled </li></ul><ul><li>Dot notation: foo.bar.baz </li></ul><ul><li>Macros </li></ul><ul><li>Filters </li></ul><ul><li>Plugins </li></ul><ul><ul><li>XML, DBI </li></ul></ul><ul><ul><li>Dates, prices, multi-column </li></ul></ul><ul><li>ttree, Splash library </li></ul>
  • 22. HTML::Template <ul><li>Pipeline </li></ul><ul><li>Mini-language </li></ul><ul><li>Cached Parse Tree </li></ul><ul><li>Fast and simple </li></ul><ul><li>Templates can be cached in shared memory or disk </li></ul>
  • 23. Honorable mentions <ul><li>ePerl </li></ul><ul><li>Apache::XPP </li></ul><ul><li>CGI::FastTemplate </li></ul><ul><li>HTML_Tree </li></ul>
  • 24. Performance <ul><li>Don’t start with your templating system! </li></ul><ul><li>Benchmarks </li></ul><ul><ul><li>http://www. chamas .com/bench/hello.tar. gz </li></ul></ul><ul><li>CGI concerns </li></ul>
  • 25. Perl Compiled Callback Just Templates Text::Template Mini-language Cached Parse Tree Pipeline Just Templates HTML::Template Perl and XSL and Mini-Language(s) Compiled or Cached Parse Tree Pipeline Framework AxKit Mini-language Repeated Parse Callback Just Templates SSI Perl Compiled Callback Framework HTML::Embperl Perl Compiled Callback Framework Apache::ASP Mini-language Compiled Pipeline Just Templates Template Toolkit Perl Compiled Callback Framework HTML::Mason Language Parsing Method Pipeline or Callback Framework or Just Templates
  • 26. Updates <ul><li>Article to be published on mod_perl list. </li></ul><ul><li>Send corrections to: </li></ul><ul><li>[email_address] </li></ul>

×