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 8. Extending the Template Toolkit

Most of the customization you are likely to perform will fall under one of two categories: creating new frontends and writing filters and plugins. However, some things cannot be handled with a new frontend or by writing a plugin, such as modifying how the provider finds templates to process or limiting access to certain plugins. Luckily, the Template Toolkit makes it easy to replace or extend any of the core components; its modular design makes replacing individual components simple. Chapter 7 gives public API details for each component.

Using and Implementing Noncore Components

Each Template Toolkit module knows about the other modules it needs to do its job, and will create instances of these objects unless one is passed to it explicitly. This means that modules are loaded and instances created on demand. The Template::Config module provides a convenient and centralized place to override core elements of the Template Toolkit, in the form of factory methods for each major component—context, filters, iterator, parser, plugins, provider, service, stash, and constants. The type of object that each method creates is, in turn, controlled by a series of variables in the $Template::Config namespace:

$CONTEXT = 'Template::Context'; $FILTERS = 'Template::Filters'; $ITERATOR = 'Template::Iterator'; $PARSER = 'Template::Parser'; $PLUGINS = 'Template::Plugins'; $PROVIDER = 'Template::Provider'; $SERVICE = 'Template::Service'; $STASH = 'Template::Stash'; ...
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.
Start your free trial

You might also like

Beginning Perl

Beginning Perl

Curtis Ovid Poe
Perl by Example

Perl by Example

Ellie Quigley
Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe
Learning Perl 6

Learning Perl 6

brian d foy

Publisher Resources

ISBN: 0596004761Supplemental ContentErrata Page