Free Books / Computers / Practical mod_perl / books


previous page: D.1. Fetching and Installing the Template Toolkitpage up: Practical mod_perl | by Stas Bekman and Eric Choletnext page: D.3. Typical Uses

D.2. Overview

Search

Titles
  • Animals
  • Architecture
  • Arts
  • Business
  • Computers
  • Crafts
  • Finance
  • Flora and Plants
  • Cooking
  • Gardening
  • Health and Healing
  • History
  • Home Improvements
  • Languages
  • New Age
  • Novels
  • Real Estate
  • Reference
  • Religion
  • Science
  • Society
  • Sports
  • Travel
  • Outdoors
  • Site Listing

Discover
  • Find Articles
  • FAQ Help Tutorials























Description

This section is from the "Practical mod_perl" book, by Stas Bekman and Eric Cholet. Also available from Amazon: Practical mod_perl

The Template Toolkit is a collection of Perl modules, scripts, and other useful bits and pieces that collectively implement a powerful template processing system for generating and manipulating content. It scans through source documents looking for special directives embedded in the text. These act as instructions to the processor to perform certain tasks.

A simple directive might just insert the value of a variable:

<a href="[% home %]">Home</a>

or perhaps include and process another template:

[% INCLUDE header
     title = 'A Dark and Stormy Night'
%]

More complex directives may make use of the powerful language constructs that the Template Toolkit provides. For example:

<h3>[% users.size %] users currently logged in:</h3>
<ul>
[% FOREACH user = users %]
   [%# 'loop' is a reference to the FOREACH iterator -%]
   <li>[% loop.count %]/[% loop.size %]: 
       <a href="[% user.home %]">[% user.name %]</a>
   [% IF user.about %]
       <p>[% user.about %]</p>
   [% END %]
   [% INCLUDE userinfo %]
   </li>
[% END %]
</ul>

Chances are that you can work out what most of the above is doing without too much explanation. That's the general idea—to keep the templates as simple and general as possible. It allows you to get a broad overview of what's going on without too much detail getting in the way.

We'll come back to this example later on and explain a little more about what's going on.

 

Continue to:

  • prev: D.1. Fetching and Installing the Template Toolkit
  • Table of Contents
  • next: D.3. Typical Uses

Books by Stas Bekman:

Tags

practical mod_perl, modperl, Apache, perl, cgi, html, scalability, free, open source, OSS, squid, high availability, linux, unix, web, www, webserver, admin, book, webmaster, tools, modperl guide, docs, documentation, help, script, eric cholet, stas bekman, performance, speed, choice









TOP
previous page: D.1. Fetching and Installing the Template Toolkitpage up: Practical mod_perl | by Stas Bekman and Eric Choletnext page: D.3. Typical Uses

© 2007 StasoSphere

[ Privacy Policy ] [ Terms of Use ] [ About Us ] [ Search ]

Last modified Mon Oct 20 15:54:42 2008