• • • • • • • Table of Contents Index Reviews Examples Reader Reviews Errata Academic Perl Template Toolkit By Darren Chamberlain, David Cross, Andy Wardley Publisher : O'Reilly Pub Date : December 2003 ISBN : 0-596-00476-1 Pages : 576 Slots : 1.0 Written by core members of the technology's development team, Perl Template Toolkit guides you through the entire process of installing, configuring, using, and extending the Template Toolkit It begins with a fastpaced but thorough tutorial on building web content with the Template Toolkit, and then walks you through generating and using data files, particularly with XML It also provides detailed information on the Template Toolkit's modules, libraries, and tools in addition to a complete reference manual • • • • • • • Table of Contents Index Reviews Examples Reader Reviews Errata Academic Perl Template Toolkit By Darren Chamberlain, David Cross, Andy Wardley Publisher : O'Reilly Pub Date : December 2003 ISBN : 0-596-00476-1 Pages : 576 Slots : 1.0 Copyright Preface Audience About this Book Conventions Used in This Book Acknowledgments Comments and Questions Chapter 1 Getting Started with the Template Toolkit Section 1.1 What the Template Toolkit Does Section 1.2 The Templating Ecosystem Section 1.3 Installing the Template Toolkit Section 1.4 Documentation and Support Section 1.5 Using the Template Toolkit Section 1.6 The Template Toolkit Language Section 1.8 Template Directives Section 1.7 Template Variables Section 1.9 Integrating and Extending the Template Toolkit Chapter 2 Building a Complete Web Site Using the Template Toolkit Section 2.1 Getting Started Section 2.2 Template Components Section 2.3 Defining Variables Section 2.5 Adding Headers and Footers Automatically Section 2.7 Wrapper and Layout Templates Section 2.9 Defining and Using Complex Data Section 2.4 Generating Many Pages Section 2.6 More Template Components Section 2.8 Menu Components Section 2.10 Assessment Chapter 3 The Template Language Section 3.1 Template Syntax Section 3.2 Template Variables Section 3.3 Virtual Methods Chapter 4 Template Directives Section 4.1 Accessing Variables Section 4.2 Accessing External Templates and Files Section 4.3 Defining Local Template Blocks Section 4.5 Conditionals Section 4.6 Filters Section 4.8 Macros Section 4.10 Exception Handling Section 4.12 Debugging Section 4.4 Loops Section 4.7 Plugins Section 4.9 Template Metadata Section 4.11 Flow Control Section 4.13 Perl Blocks Chapter 5 Filters Section 5.1 Using Filters Section 5.2 Standard Template Toolkit Filters Chapter 6 Plugins Section 6.1 Using Plugins Section 6.2 Standard Template Toolkit Plugins Chapter 7 Anatomy of the Template Toolkit Section 7.1 Template Modules Section 7.2 The Runtime Engine Section 7.3 Module Interfaces Chapter 8 Extending the Template Toolkit Section 8.1 Using and Implementing Noncore Components Section 8.2 Creating Filters Section 8.3 Creating Plugins Section 8.5 Changing the Language Section 8.4 Building a New Frontend Chapter 9 Accessing Databases Section 9.1 Using the DBI Plugin Section 9.2 Using Class::DBI Section 9.3 Using DBIx::Table2Hash Chapter 10 XML Section 10.1 Simple XML Processsing Section 10.2 Creating XML Documents Section 10.3 Processing RSS Files with XML.RSS Section 10.5 Processing XML Documents with XML.XPath Section 10.7 Using Views to Transform XML Content Section 10.4 Processing XML Documents with XML.DOM Section 10.6 Processing XML Documents with XML.LibXML Chapter 11 Advanced Static Web Page Techniques Section 11.1 Getting Started Section 11.2 Library Templates Section 11.3 Content Templates Section 11.5 Structuring Page Content Section 11.4 Navigation Components Section 11.6 Creating a New Skin Chapter 12 Dynamic Web Content and Web Applications Section 12.1 CGI Scripts Section 12.2 CGI Templates Section 12.3 Apache and mod_perl Section 12.4 A Complete Web Application Appendix A Appendix: Configuration Options Section A.1 Template Toolkit Configuration Options Section A.2 Apache::Template Configuration Options Colophon Index Copyright © 2004 O'Reilly Media, Inc Printed in the United States of America Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O'Reilly & Associates books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://safari.oreilly.com) For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly Media, Inc Perl Template Toolkit, the image of a badger, and related trade dress are trademarks of O'Reilly Media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O'Reilly Media, Inc was aware of a trademark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein Preface Perl Template Toolkit is an introduction to the Template Toolkit The Template Toolkit is most often used in the creation of web sites, but it can be used as a general text manipulation tool It is a presentation management system that allows you to separate aspects of presentation from the rest of an application, in the same way that a database allows you to separate storage concerns The information in this book is based on Version 2.10 of the Template Toolkit, released in July 2003 The Template Toolkit will continue to evolve Apart from bug fixes and minor updates, the Version 2.* branch will remain pretty much the same as it is now Version 3, expected sometime in 2004, will include new features and some changes to the internal architecture However, it is an important requirement that new versions of the Template Toolkit are backward-compatible with previous versions wherever possible Although the Template Toolkit may change in some subtle ways, the basic principles, syntax, and style are here to stay Audience This book should be useful to anyone building and maintaining web sites or other complex content systems No prior knowledge of Perl, the Template Toolkit, or HTML is required to apply the basic techniques taught in this book Some of the more advanced topics require some degree of familiarity with the Perl programming language Readers who understand the basic language constructs and idioms of Perl and who already know how to install and use Perl modules will have no trouble integrating the Template Toolkit into their existing or new projects Some chapters talk about more specific application areas: HTML, web programming, XML, and SQL, for example Experience in these areas will make the benefits of the Template Toolkit more readily apparent, but isn't required About this Book This book is divided into 12 chapters and 1 appendix Chapter 1, Getting Started with the Template Toolkit, provides an introduction to the concepts of template processing in general and to the Template Toolkit in particular It also covers how to install the Template Toolkit on your system and gives a brief tutorial on its use so that you can check that installation is successful In case it isn't, the chapter also includes pointers to other sources of information on the Template Toolkit Chapter 2, Building a Complete Web Site Using the Template Toolkit, is a tutorial on building a web site using the Template Toolkit It gives a brief overview of many of the features of the Template Toolkit that are covered in more detail later in the book Chapter 3, The Template Language, begins our detailed look at the Template Toolkit In this chapter, we look at the syntax of the Template Toolkit's presentation language Chapter 4, Template Directives, covers the syntax and use of the many templating directives that can be used from the Template Toolkit Chapter 5, Filters, takes a look at filters These are extensions to the Template Toolkit that allow you to filter your data in various ways before presenting it to your users This chapter includes a guide to the various standard filters that are included with the Template Toolkit distribution Chapter 6, Plugins, looks at the Template Toolkit plugins Plugins are another way to extend the Template Toolkit by giving your templates access to powerful external modules This chapter includes a guide to the various standard plugins that ... Using the Template Toolkit Section 1.6 The Template Toolkit Language Section 1.8 Template Directives Section 1.7 Template Variables Section 1.9 Integrating and Extending the Template Toolkit. .. errors or omissions, or for damages resulting from the use of the information contained herein Preface Perl Template Toolkit is an introduction to the Template Toolkit The Template Toolkit is most often used in the creation of web sites, but it can be used as a general text manipulation tool... includes a guide to the various standard filters that are included with the Template Toolkit distribution Chapter 6, Plugins, looks at the Template Toolkit plugins Plugins are another way to extend the Template Toolkit by giving your templates access to powerful external modules