Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Template Modules

The Template module is simply a frontend that creates and uses a Template::Service object and then pipes the output wherever you want it to go (standard output by default, or maybe a file, scalar variable, etc.). The Apache::Template module is another frontend, which uses a Template::Service::Apache object under the hood and sends the output back to the relevant Apache object. The now-familiar tpage and ttree scripts are command line-based frontends; tpage simply connects standard input and output by way of the Template Toolkit, while ttree does the same for source and destination files (with the intelligence to detect when they haven’t changed).

These frontend modules are really there only to handle any specifics of the environment in which they’re being used. Apache::Template does web-specific things, such as making form parameters and client request headers available as template variables and allowing configuration via httpd.conf. The ttree program parses command-line arguments and a configuration file. The regular Template frontend deals with standard output and writing to files. Otherwise, it is Template::Service (or a subclass) that does all the work. The process method calls $service->process and then spends most of its time figuring out where to send the results. Example 7-1 shows the process method in action.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint