Perl Template Toolkit 9781449313234, 144931323X, 9780596004767

Among the many different approaches to "templating" with Perl--such as Embperl, Mason, HTML::Template, and hun

407 25 1MB

English Pages 592 Year 2011

Report DMCA / Copyright

DOWNLOAD FILE

Perl Template Toolkit
 9781449313234, 144931323X, 9780596004767

Table of contents :
Content: Table of Contents
Preface
Audience
About this Book
Conventions Used in This Book
Comments and Questions
Acknowledgments
Andy Wardley
Darren Chamberlain
David Cross
Chapter 1: Getting Started with the Template Toolkit
What the Template Toolkit Does
The Templating Ecosystem
The Template Toolkit Is for More Than HTML
The Template Toolkit Lets You Choose Your Separation
Nonprogrammers Can Maintain Templates
The Template Toolkit Is Easy to Extend
Installing the Template Toolkit
Downloading
Installing
Documentation and Support
Viewing the Documentation. Overview of the DocumentationAccessing the Mailing List
Using the Template Toolkit
tpage
ttree
The Template Module
Template configuration options
Apache::Template Module
The Template Toolkit Language
Template Variables
Complex Variables
Lists
Hashes
Nesting list and hash definitions
Dynamic Variables
Virtual Methods
Template Directives
Variable Directives
Template Processing Directives
Loops
Conditionals
Filters, Plugins, and Macros
Integrating and Extending the Template Toolkit
Chapter 2: Building a Complete Web Site Using the Template Toolkit
Getting Started. A Single PageA "Hello World" HTML Template
Processing Templates with tpage
Template Components
Headers and Footers
The PROCESS directive
The INSERT directive
Benefits of Modularity
Defining Variables
Configuration Template
Comments
Variable values
Loading the Configuration Template
Merging directives
Generating Many Pages
Creating a Project Directory
ttree Configuration File
Running ttree for the First Time
Using a Build Script
ttree Configuration Directory
Calling ttree Through the Build Script
A Place for Everything, and Everything in Its Place
Running the Build Script. Skipping Unmodified TemplatesAdding Headers and Footers Automatically
Defining META Tags
More Template Components
The INCLUDE Directive
Setting Default Values
The DEFAULT directive
Expressions
The IF Directive
Wrapper and Layout Templates
The WRAPPER Directive
Using an Automatic Wrapper Template
Using Layout Templates
Layout Example
Side-effect wrappers
Separating layout concerns
Plugins and the USE directive
Menu Components
Simple Menu Template
The BLOCK directive
Component Libraries
The EXPOSE_BLOCKS option
The FOREACH Directive
Defining and Using Complex Data. Structured Configuration TemplatesLayered Configuration Templates
Choosing Global Variables Wisely
Passing Around Data Structures
Assessment
Chapter 3: The Template Language
Template Syntax
Text and Directives
Template parser
Parse errors
Caching templates
Flexible syntax
Template Tags
Interpolated Variables
Comments
Whitespace Chomping
Chomping flags
Chomping options
Chomping constants
Multiple Directive Tags
Side-Effect Notation
Capturing Directive Output
Template Filenames
Template Variables
What's in a Name?
Simple Data Types
Complex Data Types
Lists
Hashes.

Polecaj historie