Skip to Content
Perl Template Toolkit
book

Perl Template Toolkit

by Darren Chamberlain, Andy Wardley, David Cross
December 2003
Intermediate to advanced
590 pages
14h 14m
English
O'Reilly Media, Inc.
Content preview from Perl Template Toolkit

Chapter 3. The Template Language

While a programming language is designed to manipulate data, a presentation language is used to turn the data into plain text, HTML, or some other format.[5] As long as the data is made available to us in a textual representation when we ask for it, we really don’t need to worry too much about how it is stored or computed behind the scenes.

That’s not to say that you can’t create and manipulate variables in templates. However, their most common use is for dealing only with presentation aspects, by using variables to define colors or other layout parameters, displaying the first N search results, or sorting a list of names into alphabetical order, for example. It is unusual (but not unheard of) to use the Template Toolkit to modify data that has any lasting effect. In general, data is passed to a template and then thrown away, so it doesn’t matter if it’s changed in any way.

In this chapter, we take a closer look at the details of the Template Toolkit presentation language. The general syntax of templates comes under scrutiny first, and we give examples of how the default style can be customized using configuration options and template directives. The rest of the chapter is then dedicated to an in-depth study of variables. We describe the various data types, showing how they are defined and used in both Perl and template markup.

We concentrate on the general characteristics of the language without looking too closely at any of the specific directives ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Perl Best Practices

Perl Best Practices

Damian Conway
Advanced Perl Programming

Advanced Perl Programming

Sriram Srinivasan
Perl by Example

Perl by Example

Ellie Quigley
Perl Cookbook

Perl Cookbook

Tom Christiansen, Nathan Torkington

Publisher Resources

ISBN: 0596004761Errata Page