the most common template toolkit mistake
DESCRIPTION
This was a lightning talk presented at YAPC::NA 2011.TRANSCRIPT
The Most Common Template Toolkit Mistake
Perrin HarkinsWe Also Walk Dogs
Yesterday, Uri did a lighting talk
Template::Simple has a benchmark scriptApparently it is faster and lighter than Template Toolkit
Years ago, I did a talk on templating systemshttp://tmpl.notlong.comSince then, many people have told me about their new module
People often break Template Toolkit's cachemy $tt = Template->new({ INCLUDE_PATH => '/usr/local/templates'}) || die "$Template::ERROR\n";
$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 refIs 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