SlideShare a Scribd company logo
The Most Common
 Template Toolkit Mistake
       Perrin Harkins
      We Also Walk Dogs
Yesterday, Uri did a lighting talk

Template::Simple has a benchmark script
Apparently it is faster and lighter than Template Toolkit
Years ago, I did a talk on templating
systems
http://tmpl.notlong.com
Since then, many people have told me about their new
module
People often break Template
Toolkit's cache
my $tt = Template->new({ INCLUDE_PATH =>
 '/usr/local/templates'})
 || die "$Template::ERRORn";

$tt>process( 'letters/overdrawn', $vars)
   || die $tt->error(), "n";




       Don't throw away your Template instance!
                 The cache is in there!
Uri's benchmark didn't do that

It did something else: template in a scalar ref
Is that a bug?

How can you fix it?

Subclass Template::Provider, e.g. Template::Provider::MD5

Temp file
Template::Simple is still much faster

But Template Toolkit isn't as slow as it looked.

More than 300% faster than before.
Why I like slow and heavy templates

Separates presentation code from model and controller
 ● Keeps display things that wouldn't make sense in a cron
   job in your output layer
 ● Format dates and numbers
 ● Put things in multiple columns
 ● Display objects
 ● Maybe sort things?
Mason, etc. are fine for this, not just TT

More Related Content

PPT
Php tips and tricks by omar bin sulaiman
ODP
Chart clicker presentation
ODP
The Essential Perl Hacker's Toolkit
PPTX
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
PDF
Software Testing & PHPSpec
ODP
Perl Teach-In (part 1)
PPTX
Ot performance webinar
ODP
Php tips and tricks by omar bin sulaiman
Chart clicker presentation
The Essential Perl Hacker's Toolkit
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Software Testing & PHPSpec
Perl Teach-In (part 1)
Ot performance webinar

Similar to The Most Common Template Toolkit Mistake (20)

PDF
The Why and What of Pattern Lab
PPTX
Ajug april 2011
PDF
No Hugging, No Learning
ODP
LPW 2007 - Perl Plumbing
ODP
How To Contribute Drupalcon
PDF
Twig: Friendly Curly Braces Invade Your Templates!
PPTX
AtoM's Command Line Tasks - An Introduction
PDF
PuppetConf 2016: Puppet 4.x: The Low WAT-tage Edition – Nick Fagerlund, Puppet
PPT
En story of cakephp2.0
PDF
Drupal 8: A story of growing up and getting off the island
PDF
Reproducible datascience [with Terraform]
PDF
Puppet for Sys Admins
PDF
Learning PHP for Drupal Theming, DC Chicago 2009
PDF
How To Contribute To Drupal Drupal - DrupalCon Paris
PDF
Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...
KEY
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
PDF
Drupal Devministration
PPTX
Clean Code: Stop wasting my time
PDF
Building User-Centred Websites with Drupal
PDF
Developing IT infrastructures with Puppet
The Why and What of Pattern Lab
Ajug april 2011
No Hugging, No Learning
LPW 2007 - Perl Plumbing
How To Contribute Drupalcon
Twig: Friendly Curly Braces Invade Your Templates!
AtoM's Command Line Tasks - An Introduction
PuppetConf 2016: Puppet 4.x: The Low WAT-tage Edition – Nick Fagerlund, Puppet
En story of cakephp2.0
Drupal 8: A story of growing up and getting off the island
Reproducible datascience [with Terraform]
Puppet for Sys Admins
Learning PHP for Drupal Theming, DC Chicago 2009
How To Contribute To Drupal Drupal - DrupalCon Paris
Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
Drupal Devministration
Clean Code: Stop wasting my time
Building User-Centred Websites with Drupal
Developing IT infrastructures with Puppet
Ad

More from Perrin Harkins (13)

PDF
PyGotham 2014 Introduction to Profiling
PDF
Introduction to performance tuning perl web applications
PDF
Care and feeding notes
PDF
Scalable talk notes
PDF
Low maintenance perl notes
ODP
Choosing a Web Architecture for Perl
PDF
Building Scalable Websites with Perl
PPT
Efficient Shared Data in Perl
PPT
Choosing a Templating System
PDF
Scaling Databases with DBIx::Router
PDF
Low-Maintenance Perl
PDF
Care and Feeding of Large Web Applications
PDF
Top 10 Perl Performance Tips
PyGotham 2014 Introduction to Profiling
Introduction to performance tuning perl web applications
Care and feeding notes
Scalable talk notes
Low maintenance perl notes
Choosing a Web Architecture for Perl
Building Scalable Websites with Perl
Efficient Shared Data in Perl
Choosing a Templating System
Scaling Databases with DBIx::Router
Low-Maintenance Perl
Care and Feeding of Large Web Applications
Top 10 Perl Performance Tips
Ad

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
Teaching material agriculture food technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
cuic standard and advanced reporting.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Approach and Philosophy of On baking technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Machine learning based COVID-19 study performance prediction
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Teaching material agriculture food technology
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
cuic standard and advanced reporting.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Diabetes mellitus diagnosis method based random forest with bat algorithm
A comparative analysis of optical character recognition models for extracting...
Advanced methodologies resolving dimensionality complications for autism neur...
Spectral efficient network and resource selection model in 5G networks
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Programs and apps: productivity, graphics, security and other tools
Approach and Philosophy of On baking technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
Machine learning based COVID-19 study performance prediction
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

The Most Common Template Toolkit Mistake

  • 1. The Most Common  Template Toolkit Mistake Perrin Harkins We Also Walk Dogs
  • 2. Yesterday, Uri did a lighting talk Template::Simple has a benchmark script Apparently it is faster and lighter than Template Toolkit
  • 3. Years ago, I did a talk on templating systems http://tmpl.notlong.com Since then, many people have told me about their new module
  • 4. People often break Template Toolkit's cache my $tt = Template->new({ INCLUDE_PATH => '/usr/local/templates'}) || die "$Template::ERRORn"; $tt>process( 'letters/overdrawn', $vars) || die $tt->error(), "n"; Don't throw away your Template instance! The cache is in there!
  • 5. Uri's benchmark didn't do that It did something else: template in a scalar ref Is that a bug? How can you fix it? Subclass Template::Provider, e.g. Template::Provider::MD5 Temp file
  • 6. Template::Simple is still much faster But Template Toolkit isn't as slow as it looked. More than 300% faster than before.
  • 7. Why I like slow and heavy templates Separates presentation code from model and controller ● Keeps display things that wouldn't make sense in a cron job in your output layer ● Format dates and numbers ● Put things in multiple columns ● Display objects ● Maybe sort things? Mason, etc. are fine for this, not just TT