<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.soylentnews.org/index.php?action=history&amp;feed=atom&amp;title=TemplateTutorialWeb</id>
	<title>TemplateTutorialWeb - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.soylentnews.org/index.php?action=history&amp;feed=atom&amp;title=TemplateTutorialWeb"/>
	<link rel="alternate" type="text/html" href="https://wiki.soylentnews.org/index.php?title=TemplateTutorialWeb&amp;action=history"/>
	<updated>2026-06-10T19:05:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.4</generator>
	<entry>
		<id>https://wiki.soylentnews.org/index.php?title=TemplateTutorialWeb&amp;diff=6263&amp;oldid=prev</id>
		<title>FunPika: added Category:Development using HotCat</title>
		<link rel="alternate" type="text/html" href="https://wiki.soylentnews.org/index.php?title=TemplateTutorialWeb&amp;diff=6263&amp;oldid=prev"/>
		<updated>2014-03-15T15:40:38Z</updated>

		<summary type="html">&lt;p&gt;added &lt;a href=&quot;/wiki/Category:Development&quot; title=&quot;Category:Development&quot;&gt;Category:Development&lt;/a&gt; using &lt;a href=&quot;/wiki/Help:Gadget-HotCat&quot; title=&quot;Help:Gadget-HotCat&quot;&gt;HotCat&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:40, 15 March 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l733&quot;&gt;Line 733:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 733:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;perl v5.10.1                      2013-07-23        Template::Tutorial::Web(3)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;perl v5.10.1                      2013-07-23        Template::Tutorial::Web(3)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Development]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>FunPika</name></author>
	</entry>
	<entry>
		<id>https://wiki.soylentnews.org/index.php?title=TemplateTutorialWeb&amp;diff=5288&amp;oldid=prev</id>
		<title>50.45.173.59 at 17:17, 28 February 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.soylentnews.org/index.php?title=TemplateTutorialWeb&amp;diff=5288&amp;oldid=prev"/>
		<updated>2014-02-28T17:17:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:17, 28 February 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[CssWork]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[CssWork&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] [[TemplateAnatomy&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>50.45.173.59</name></author>
	</entry>
	<entry>
		<id>https://wiki.soylentnews.org/index.php?title=TemplateTutorialWeb&amp;diff=5287&amp;oldid=prev</id>
		<title>50.45.173.59: Created page with &quot;CssWork   [root@slashcode man3]# man Template::Tutorial::Web | cat Template::Tutorial::WeUser Contributed Perl DocumentTemplate::Tutorial::Web(3)   &lt;pre&gt; NAME        Templ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.soylentnews.org/index.php?title=TemplateTutorialWeb&amp;diff=5287&amp;oldid=prev"/>
		<updated>2014-02-28T17:15:05Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/wiki/CssWork&quot; class=&quot;mw-redirect&quot; title=&quot;CssWork&quot;&gt;CssWork&lt;/a&gt;   [root@slashcode man3]# man Template::Tutorial::Web | cat Template::Tutorial::WeUser Contributed Perl DocumentTemplate::Tutorial::Web(3)   &amp;lt;pre&amp;gt; NAME        Templ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[CssWork]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@slashcode man3]# man Template::Tutorial::Web | cat&lt;br /&gt;
Template::Tutorial::WeUser Contributed Perl DocumentTemplate::Tutorial::Web(3)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NAME&lt;br /&gt;
       Template::Tutorial::Web - Generating Web Content Using the Template&lt;br /&gt;
       Toolkit&lt;br /&gt;
&lt;br /&gt;
Overview&lt;br /&gt;
       This tutorial document provides a introduction to the Template Toolkit&lt;br /&gt;
       and demonstrates some of the typical ways it may be used for generating&lt;br /&gt;
       web content. It covers the generation of static pages from templates&lt;br /&gt;
       using the tpage and ttree scripts and then goes on to show dynamic&lt;br /&gt;
       content generation using CGI scripts and Apache/mod_perl handlers.&lt;br /&gt;
&lt;br /&gt;
       Various features of the Template Toolkit are introduced and described&lt;br /&gt;
       briefly and explained by use of example. For further information, see&lt;br /&gt;
       Template, Template::Manual and the various sections within it. e.g&lt;br /&gt;
&lt;br /&gt;
           perldoc Template                    # Template.pm module usage&lt;br /&gt;
           perldoc Template::Manual            # index to manual&lt;br /&gt;
           perldoc Template::Manual::Config    # e.g. configuration options&lt;br /&gt;
&lt;br /&gt;
       The documentation is also available in HTML format to read online, or&lt;br /&gt;
       download from the Template Toolkit web site:&lt;br /&gt;
&lt;br /&gt;
           http://template-toolkit.org/docs/&lt;br /&gt;
&lt;br /&gt;
Introduction&lt;br /&gt;
       The Template Toolkit is a set of Perl modules which collectively&lt;br /&gt;
       implement a template processing system.&lt;br /&gt;
&lt;br /&gt;
       A template is a text document with special markup tags embedded in it.&lt;br /&gt;
       By default, the Template Toolkit uses ’&amp;quot;[%&amp;quot;’ and ’&amp;quot;%]&amp;quot;’ to denote the&lt;br /&gt;
       start and end of a tag.  Here’s an example:&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE header %]&lt;br /&gt;
&lt;br /&gt;
           People of [% planet %], your attention please.&lt;br /&gt;
&lt;br /&gt;
           This is [% captain %] of the&lt;br /&gt;
           Galactic Hyperspace Planning Council.&lt;br /&gt;
&lt;br /&gt;
           As you will no doubt be aware, the plans&lt;br /&gt;
           for development of the outlying regions&lt;br /&gt;
           of the Galaxy require the building of a&lt;br /&gt;
           hyperspatial express route through your&lt;br /&gt;
           star system, and regrettably your planet&lt;br /&gt;
           is one of those scheduled for destruction.&lt;br /&gt;
&lt;br /&gt;
           The process will take slightly less than&lt;br /&gt;
           [% time %].&lt;br /&gt;
&lt;br /&gt;
           Thank you.&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE footer %]&lt;br /&gt;
&lt;br /&gt;
       Tags can contain simple variables (like &amp;quot;planet&amp;quot; and &amp;quot;captain&amp;quot;) and&lt;br /&gt;
       more complex directives that start with an upper case keyword (like&lt;br /&gt;
       &amp;quot;INCLUDE&amp;quot;).  A directive is an instruction that tells the template&lt;br /&gt;
       processor to perform some action, like processing another template&lt;br /&gt;
       (&amp;quot;header&amp;quot; and &amp;quot;footer&amp;quot; in this example) and inserting the output into&lt;br /&gt;
       the current template. In fact, the simple variables we mentioned are&lt;br /&gt;
       actually &amp;quot;GET&amp;quot; directives, but the &amp;quot;GET&amp;quot; keyword is optional.&lt;br /&gt;
&lt;br /&gt;
           People of [% planet %], your attention please.      # short form&lt;br /&gt;
           People of [% GET planet %], your attention please.  # long form&lt;br /&gt;
&lt;br /&gt;
       Other directives include &amp;quot;SET&amp;quot; to set a variable value (the &amp;quot;SET&amp;quot;&lt;br /&gt;
       keyword is also optional), &amp;quot;FOREACH&amp;quot; to iterate through a list of&lt;br /&gt;
       values, and &amp;quot;IF&amp;quot;, &amp;quot;UNLESS&amp;quot;, &amp;quot;ELSIF&amp;quot; and &amp;quot;ELSE&amp;quot; to declare conditional&lt;br /&gt;
       blocks.&lt;br /&gt;
&lt;br /&gt;
       The Template Toolkit processes all text files equally, regardless of&lt;br /&gt;
       what kind of content they contain.  So you can use TT to generate HTML,&lt;br /&gt;
       XML, CSS, Javascript, Perl, RTF, LaTeX, or any other text-based format.&lt;br /&gt;
       In this tutorial, however, we’ll be concentrating on generating HTML&lt;br /&gt;
       for web pages.&lt;br /&gt;
&lt;br /&gt;
Generating Static Web Content&lt;br /&gt;
       Here’s an example of a template used to generate an HTML document.&lt;br /&gt;
&lt;br /&gt;
           [%  INCLUDE header&lt;br /&gt;
                 title = 'This is an HTML example';&lt;br /&gt;
&lt;br /&gt;
               pages = [&lt;br /&gt;
                 { url   = 'http://foo.org'&lt;br /&gt;
                   title = 'The Foo Organisation'&lt;br /&gt;
                 }&lt;br /&gt;
                 { url   = 'http://bar.org'&lt;br /&gt;
                   title = 'The Bar Organisation'&lt;br /&gt;
                 }&lt;br /&gt;
               ]&lt;br /&gt;
           %]&lt;br /&gt;
              &amp;lt;h1&amp;gt;Some Interesting Links&amp;lt;/h1&amp;gt;&lt;br /&gt;
              &amp;lt;ul&amp;gt;&lt;br /&gt;
           [%  FOREACH page IN pages %]&lt;br /&gt;
                &amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;[% page.url %]&amp;quot;&amp;gt;[% page.title %]&amp;lt;/a&amp;gt;&lt;br /&gt;
           [%  END %]&lt;br /&gt;
              &amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE footer %]&lt;br /&gt;
&lt;br /&gt;
       This example shows how the &amp;quot;INCLUDE&amp;quot; directive is used to load and&lt;br /&gt;
       process separate ’&amp;quot;header&amp;quot;’ and ’&amp;quot;footer&amp;quot;’ template files, including&lt;br /&gt;
       the output in the current document.  These files might look something&lt;br /&gt;
       like this:&lt;br /&gt;
&lt;br /&gt;
       header:&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;html&amp;gt;&lt;br /&gt;
             &amp;lt;head&amp;gt;&lt;br /&gt;
               &amp;lt;title&amp;gt;[% title %]&amp;lt;/title&amp;gt;&lt;br /&gt;
             &amp;lt;/head&amp;gt;&lt;br /&gt;
             &amp;lt;body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       footer:&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;div class=&amp;quot;copyright&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;amp;copy; Copyright 2007 Arthur Dent&lt;br /&gt;
               &amp;lt;/div&amp;gt;&lt;br /&gt;
             &amp;lt;/body&amp;gt;&lt;br /&gt;
           &amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       The example also uses the &amp;quot;FOREACH&amp;quot; directive to iterate through the&lt;br /&gt;
       ’&amp;quot;pages&amp;quot;’ list to build a table of links. In this example, we have&lt;br /&gt;
       defined this list within the template to contain a number of hash&lt;br /&gt;
       references, each containing a ’&amp;quot;url&amp;quot;’ and ’&amp;quot;title&amp;quot;’ member. The&lt;br /&gt;
       &amp;quot;FOREACH&amp;quot; directive iterates through the list, aliasing ’&amp;quot;page&amp;quot;’ to&lt;br /&gt;
       each item (in this case, hash array references). The &amp;quot;[% page.url %]&amp;quot;&lt;br /&gt;
       and &amp;quot;[% page.title %]&amp;quot; directives then access the individual values in&lt;br /&gt;
       the hash arrays and insert them into the document.&lt;br /&gt;
&lt;br /&gt;
   Using tpage&lt;br /&gt;
       Having created a template file we can now process it to generate some&lt;br /&gt;
       real output. The quickest and easiest way to do this is to use the&lt;br /&gt;
       tpage script. This is provided as part of the Template Toolkit and&lt;br /&gt;
       should be installed in your usual Perl bin directory.&lt;br /&gt;
&lt;br /&gt;
       Assuming you saved your template file as example.html, you would run&lt;br /&gt;
       the command:&lt;br /&gt;
&lt;br /&gt;
           $ tpage example.html&lt;br /&gt;
&lt;br /&gt;
       This will process the template file, sending the output to &amp;quot;STDOUT&amp;quot;&lt;br /&gt;
       (i.e.  whizzing past you on the screen). You may want to redirect the&lt;br /&gt;
       output to a file but be careful not to specify the same name as the&lt;br /&gt;
       template file, or you’ll overwrite it. You may want to use one prefix&lt;br /&gt;
       for your templates (e.g.  ’&amp;quot;.tt&amp;quot;’) and another (e.g. ’&amp;quot;.html&amp;quot;’) for the&lt;br /&gt;
       output files.&lt;br /&gt;
&lt;br /&gt;
           $ tpage example.tt &amp;gt; example.html&lt;br /&gt;
&lt;br /&gt;
       Or you can redirect the output to another directory. e.g.&lt;br /&gt;
&lt;br /&gt;
           $ tpage templates/example.tt &amp;gt; html/example.html&lt;br /&gt;
&lt;br /&gt;
       The output generated would look like this:&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;html&amp;gt;&lt;br /&gt;
             &amp;lt;head&amp;gt;&lt;br /&gt;
               &amp;lt;title&amp;gt;This is an HTML example&amp;lt;/title&amp;gt;&lt;br /&gt;
             &amp;lt;/head&amp;gt;&lt;br /&gt;
             &amp;lt;body&amp;gt;&lt;br /&gt;
               &amp;lt;h1&amp;gt;Some Interesting Links&amp;lt;/h1&amp;gt;&lt;br /&gt;
               &amp;lt;ul&amp;gt;&lt;br /&gt;
                 &amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;http://foo.org&amp;quot;&amp;gt;The Foo Organsiation&amp;lt;/a&amp;gt;&lt;br /&gt;
                 &amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;http://bar.org&amp;quot;&amp;gt;The Bar Organsiation&amp;lt;/a&amp;gt;&lt;br /&gt;
               &amp;lt;/ul&amp;gt;&lt;br /&gt;
               &amp;lt;div class=&amp;quot;copyright&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;amp;copy; Copyright 2007 Arthur Dent&lt;br /&gt;
               &amp;lt;/div&amp;gt;&lt;br /&gt;
             &amp;lt;/body&amp;gt;&lt;br /&gt;
           &amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       The header and footer template files have been included (assuming you&lt;br /&gt;
       created them and they’re in the current directory) and the link data&lt;br /&gt;
       has been built into an HTML list.&lt;br /&gt;
&lt;br /&gt;
   Using ttree&lt;br /&gt;
       The tpage script gives you a simple and easy way to process a single&lt;br /&gt;
       template without having to write any Perl code. The&lt;br /&gt;
       &amp;lt;ttree:Template::Tools::ttree&amp;gt; script, also distributed as part of the&lt;br /&gt;
       Template Toolkit, provides a more flexible way to process a number of&lt;br /&gt;
       template documents in one go.&lt;br /&gt;
&lt;br /&gt;
       The first time you run the script, it will ask you if it should create&lt;br /&gt;
       a configuration file (.ttreerc) in your home directory. Answer &amp;quot;y&amp;quot; to&lt;br /&gt;
       have it create the file.&lt;br /&gt;
&lt;br /&gt;
       The &amp;lt;ttree:Template::Tools::ttree&amp;gt; documentation describes how you can&lt;br /&gt;
       change the location of this file and also explains the syntax and&lt;br /&gt;
       meaning of the various options in the file. Comments are written to the&lt;br /&gt;
       sample configuration file which should also help.&lt;br /&gt;
&lt;br /&gt;
       In brief, the configuration file describes the directories in which&lt;br /&gt;
       template files are to be found (&amp;quot;src&amp;quot;), where the corresponding output&lt;br /&gt;
       should be written to (&amp;quot;dest&amp;quot;), and any other directories (&amp;quot;lib&amp;quot;) that&lt;br /&gt;
       may contain template files that you plan to &amp;quot;INCLUDE&amp;quot; into your source&lt;br /&gt;
       documents. You can also specify processing options (such as &amp;quot;verbose&amp;quot;&lt;br /&gt;
       and &amp;quot;recurse&amp;quot;) and provide regular expression to match files that you&lt;br /&gt;
       don’t want to process (&amp;quot;ignore&amp;quot;, &amp;quot;accept&amp;quot;)&amp;gt; or should be copied instead&lt;br /&gt;
       of being processed as templates (&amp;quot;copy&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
       An example .ttreerc file is shown here:&lt;br /&gt;
&lt;br /&gt;
       $HOME/.ttreerc:&lt;br /&gt;
&lt;br /&gt;
           verbose&lt;br /&gt;
           recurse&lt;br /&gt;
&lt;br /&gt;
           # this is where I keep other ttree config files&lt;br /&gt;
           cfg = ~/.ttree&lt;br /&gt;
&lt;br /&gt;
           src  = ~/websrc/src&lt;br /&gt;
           lib  = ~/websrc/lib&lt;br /&gt;
           dest = ~/public_html/test&lt;br /&gt;
&lt;br /&gt;
           ignore = \b(CVS|RCS)\b&lt;br /&gt;
           ignore = ^#&lt;br /&gt;
&lt;br /&gt;
       You can create many different configuration files and store them in the&lt;br /&gt;
       directory specified in the &amp;quot;cfg&amp;quot; option, shown above.  You then add the&lt;br /&gt;
       &amp;quot;-f filename&amp;quot; option to &amp;quot;ttree&amp;quot; to have it read that file.&lt;br /&gt;
&lt;br /&gt;
       When you run the script, it compares all the files in the &amp;quot;src&amp;quot;&lt;br /&gt;
       directory (including those in sub-directories if the &amp;quot;recurse&amp;quot; option&lt;br /&gt;
       is set), with those in the &amp;quot;dest&amp;quot; directory.  If the destination file&lt;br /&gt;
       doesn’t exist or has an earlier modification time than the&lt;br /&gt;
       corresponding source file, then the source will be processed with the&lt;br /&gt;
       output written to the destination file.  The &amp;quot;-a&amp;quot; option forces all&lt;br /&gt;
       files to be processed, regardless of modification times.&lt;br /&gt;
&lt;br /&gt;
       The script doesn’t process any of the files in the &amp;quot;lib&amp;quot; directory, but&lt;br /&gt;
       it does add it to the &amp;quot;INCLUDE_PATH&amp;quot; for the template processor so that&lt;br /&gt;
       it can locate these files via an &amp;quot;INCLUDE&amp;quot;, &amp;quot;PROCESS&amp;quot; or &amp;quot;WRAPPER&amp;quot;&lt;br /&gt;
       directive.  Thus, the &amp;quot;lib&amp;quot; directory is an excellent place to keep&lt;br /&gt;
       template elements such as header, footers, etc., that aren’t complete&lt;br /&gt;
       documents in their own right.&lt;br /&gt;
&lt;br /&gt;
       You can also specify various Template Toolkit options from the&lt;br /&gt;
       configuration file. Consult the ttree documentation and help summary&lt;br /&gt;
       (&amp;quot;ttree -h&amp;quot;) for full details. e.g.&lt;br /&gt;
&lt;br /&gt;
       $HOME/.ttreerc:&lt;br /&gt;
&lt;br /&gt;
           pre_process = config&lt;br /&gt;
           interpolate&lt;br /&gt;
           post_chomp&lt;br /&gt;
&lt;br /&gt;
       The &amp;quot;pre_process&amp;quot; option allows you to specify a template file which&lt;br /&gt;
       should be processed before each file.  Unsurprisingly, there’s also a&lt;br /&gt;
       &amp;quot;post_process&amp;quot; option to add a template after each file.  In the&lt;br /&gt;
       fragment above, we have specified that the &amp;quot;config&amp;quot; template should be&lt;br /&gt;
       used as a prefix template.  We can create this file in the &amp;quot;lib&amp;quot;&lt;br /&gt;
       directory and use it to define some common variables, including those&lt;br /&gt;
       web page links we defined earlier and might want to re-use in other&lt;br /&gt;
       templates.  We could also include an HTML header, title, or menu bar in&lt;br /&gt;
       this file which would then be prepended to each and every template&lt;br /&gt;
       file, but for now we’ll keep all that in a separate &amp;quot;header&amp;quot; file.&lt;br /&gt;
&lt;br /&gt;
       $lib/config:&lt;br /&gt;
&lt;br /&gt;
           [% root     = '~/abw'&lt;br /&gt;
              home     = &amp;quot;$root/index.html&amp;quot;&lt;br /&gt;
              images   = &amp;quot;$root/images&amp;quot;&lt;br /&gt;
              email    = 'abw@wardley.org'&lt;br /&gt;
              graphics = 1&lt;br /&gt;
              webpages = [&lt;br /&gt;
                { url =&amp;gt; 'http://foo.org', title =&amp;gt; 'The Foo Organsiation' }&lt;br /&gt;
                { url =&amp;gt; 'http://bar.org', title =&amp;gt; 'The Bar Organsiation' }&lt;br /&gt;
              ]&lt;br /&gt;
           %]&lt;br /&gt;
&lt;br /&gt;
       Assuming you’ve created or copied the &amp;quot;header&amp;quot; and &amp;quot;footer&amp;quot; files from&lt;br /&gt;
       the earlier example into your &amp;quot;lib&amp;quot; directory, you can now start to&lt;br /&gt;
       create web pages like the following in your &amp;quot;src&amp;quot; directory and process&lt;br /&gt;
       them with &amp;quot;ttree&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
       $src/newpage.html:&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE header&lt;br /&gt;
              title = 'Another Template Toolkit Test Page'&lt;br /&gt;
           %]&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;a href=&amp;quot;[% home %]&amp;quot;&amp;gt;Home&amp;lt;/a&amp;gt;&lt;br /&gt;
               &amp;lt;a href=&amp;quot;mailto:[% email %]&amp;quot;&amp;gt;Email&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
           [% IF graphics %]&lt;br /&gt;
               &amp;lt;img src=&amp;quot;[% images %]/logo.gif&amp;quot; align=right width=60 height=40&amp;gt;&lt;br /&gt;
           [% END %]&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE footer %]&lt;br /&gt;
&lt;br /&gt;
       Here we’ve shown how pre-defined variables can be used as flags to&lt;br /&gt;
       enable certain feature (e.g. &amp;quot;graphics&amp;quot;) and to specify common items&lt;br /&gt;
       such as an email address and URL’s for the home page, images directory&lt;br /&gt;
       and so on.  This approach allows you to define these values once so&lt;br /&gt;
       that they’re consistent across all pages and can easily be changed to&lt;br /&gt;
       new values.&lt;br /&gt;
&lt;br /&gt;
       When you run ttree, you should see output similar to the following&lt;br /&gt;
       (assuming you have the verbose flag set).&lt;br /&gt;
&lt;br /&gt;
           ttree 2.9 (Template Toolkit version 2.20)&lt;br /&gt;
&lt;br /&gt;
                Source: /home/abw/websrc/src&lt;br /&gt;
           Destination: /home/abw/public_html/test&lt;br /&gt;
          Include Path: [ /home/abw/websrc/lib ]&lt;br /&gt;
                Ignore: [ \b(CVS|RCS)\b, ^# ]&lt;br /&gt;
                  Copy: [  ]&lt;br /&gt;
                Accept: [ * ]&lt;br /&gt;
&lt;br /&gt;
           + newpage.html&lt;br /&gt;
&lt;br /&gt;
       The &amp;quot;+&amp;quot; in front of the &amp;quot;newpage.html&amp;quot; filename shows that the file was&lt;br /&gt;
       processed, with the output being written to the destination directory.&lt;br /&gt;
       If you run the same command again, you’ll see the following line&lt;br /&gt;
       displayed instead showing a &amp;quot;-&amp;quot; and giving a reason why the file wasn’t&lt;br /&gt;
       processed.&lt;br /&gt;
&lt;br /&gt;
           - newpage.html                     (not modified)&lt;br /&gt;
&lt;br /&gt;
       It has detected a &amp;quot;newpage.html&amp;quot; in the destination directory which is&lt;br /&gt;
       more recent than that in the source directory and so hasn’t bothered to&lt;br /&gt;
       waste time re-processing it.  To force all files to be processed, use&lt;br /&gt;
       the &amp;quot;-a&amp;quot; option.  You can also specify one or more filenames as command&lt;br /&gt;
       line arguments to &amp;quot;ttree&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
           tpage newpage.html&lt;br /&gt;
&lt;br /&gt;
       This is what the destination page looks like.&lt;br /&gt;
&lt;br /&gt;
       $dest/newpage.html:&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;html&amp;gt;&lt;br /&gt;
             &amp;lt;head&amp;gt;&lt;br /&gt;
               &amp;lt;title&amp;gt;Another Template Toolkit Test Page&amp;lt;/title&amp;gt;&lt;br /&gt;
             &amp;lt;/head&amp;gt;&lt;br /&gt;
             &amp;lt;body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;a href=&amp;quot;~/abw/index.html&amp;quot;&amp;gt;Home&amp;lt;/a&amp;gt;&lt;br /&gt;
               &amp;lt;a href=&amp;quot;mailto:abw@wardley.org&amp;quot;&amp;gt;Email me&amp;lt;/a&amp;gt;&lt;br /&gt;
               &amp;lt;img src=&amp;quot;~/abw/images/logo.gif&amp;quot; align=right width=60 height=40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
               &amp;lt;div class=&amp;quot;copyright&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;amp;copy; Copyright 2007 Arthur Dent&lt;br /&gt;
               &amp;lt;/div&amp;gt;&lt;br /&gt;
             &amp;lt;/body&amp;gt;&lt;br /&gt;
           &amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       You can add as many documents as you like to the &amp;quot;src&amp;quot; directory and&lt;br /&gt;
       &amp;quot;ttree&amp;quot; will apply the same process to them all.  In this way, it is&lt;br /&gt;
       possible to build an entire tree of static content for a web site with&lt;br /&gt;
       a single command.  The added benefit is that you can be assured of&lt;br /&gt;
       consistency in links, header style, or whatever else you choose to&lt;br /&gt;
       implement in terms of common templates elements or variables.&lt;br /&gt;
&lt;br /&gt;
Dynamic Content Generation Via CGI Script&lt;br /&gt;
       The Template module provides a simple front-end to the Template Toolkit&lt;br /&gt;
       for use in CGI scripts and Apache/mod_perl handlers. Simply &amp;quot;use&amp;quot; the&lt;br /&gt;
       Template module, create an object instance with the new() method and&lt;br /&gt;
       then call the process() method on the object, passing the name of the&lt;br /&gt;
       template file as a parameter. The second parameter passed is a&lt;br /&gt;
       reference to a hash array of variables that we want made available to&lt;br /&gt;
       the template:&lt;br /&gt;
&lt;br /&gt;
           #!/usr/bin/perl&lt;br /&gt;
           use strict;&lt;br /&gt;
           use warnings;&lt;br /&gt;
           use Template;&lt;br /&gt;
&lt;br /&gt;
           my $file = 'src/greeting.html';&lt;br /&gt;
           my $vars = {&lt;br /&gt;
              message  =&amp;gt; &amp;quot;Hello World\n&amp;quot;&lt;br /&gt;
           };&lt;br /&gt;
&lt;br /&gt;
           my $template = Template-&amp;gt;new();&lt;br /&gt;
&lt;br /&gt;
           $template-&amp;gt;process($file, $vars)&lt;br /&gt;
               || die &amp;quot;Template process failed: &amp;quot;, $template-&amp;gt;error(), &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
       So that our scripts will work with the same template files as our&lt;br /&gt;
       earlier examples, we’ll can add some configuration options to the&lt;br /&gt;
       constructor to tell it about our environment:&lt;br /&gt;
&lt;br /&gt;
           my $template-&amp;gt;new({&lt;br /&gt;
               # where to find template files&lt;br /&gt;
               INCLUDE_PATH =&amp;gt; ['/home/abw/websrc/src', '/home/abw/websrc/lib'],&lt;br /&gt;
               # pre-process lib/config to define any extra values&lt;br /&gt;
               PRE_PROCESS  =&amp;gt; 'config',&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       Note that here we specify the &amp;quot;config&amp;quot; file as a &amp;quot;PRE_PROCESS&amp;quot; option.&lt;br /&gt;
       This means that the templates we process can use the same global&lt;br /&gt;
       variables defined earlier for our static pages.  We don’t have to&lt;br /&gt;
       replicate their definitions in this script.  However, we can supply&lt;br /&gt;
       additional data and functionality specific to this script via the hash&lt;br /&gt;
       of variables that we pass to the &amp;quot;process()&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
       These entries in this hash may contain simple text or other values,&lt;br /&gt;
       references to lists, others hashes, sub-routines or objects.  The&lt;br /&gt;
       Template Toolkit will automatically apply the correct procedure to&lt;br /&gt;
       access these different types when you use the variables in a template.&lt;br /&gt;
&lt;br /&gt;
       Here’s a more detailed example to look over.  Amongst the different&lt;br /&gt;
       template variables we define in $vars, we create a reference to a CGI&lt;br /&gt;
       object and a &amp;quot;get_user_projects()&amp;quot; sub-routine.&lt;br /&gt;
&lt;br /&gt;
           #!/usr/bin/perl&lt;br /&gt;
           use strict;&lt;br /&gt;
           use warnings;&lt;br /&gt;
           use Template;&lt;br /&gt;
           use CGI;&lt;br /&gt;
&lt;br /&gt;
           $| = 1;&lt;br /&gt;
           print &amp;quot;Content-type: text/html\n\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
           my $file = 'userinfo.html';&lt;br /&gt;
           my $vars = {&lt;br /&gt;
               'version'  =&amp;gt; 3.14,&lt;br /&gt;
               'days'     =&amp;gt; [ qw( mon tue wed thu fri sat sun ) ],&lt;br /&gt;
               'worklist' =&amp;gt; \&amp;amp;get_user_projects,&lt;br /&gt;
               'cgi'      =&amp;gt; CGI-&amp;gt;new(),&lt;br /&gt;
               'me'       =&amp;gt; {&lt;br /&gt;
                   'id'     =&amp;gt; 'abw',&lt;br /&gt;
                   'name'   =&amp;gt; 'Andy Wardley',&lt;br /&gt;
               },&lt;br /&gt;
           };&lt;br /&gt;
&lt;br /&gt;
           sub get_user_projects {&lt;br /&gt;
               my $user = shift;&lt;br /&gt;
               my @projects = ...   # do something to retrieve data&lt;br /&gt;
               return \@projects;&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           my $template = Template-&amp;gt;new({&lt;br /&gt;
               INCLUDE_PATH =&amp;gt; '/home/abw/websrc/src:/home/abw/websrc/lib',&lt;br /&gt;
               PRE_PROCESS  =&amp;gt; 'config',&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
           $template-&amp;gt;process($file, $vars)&lt;br /&gt;
               || die $template-&amp;gt;error();&lt;br /&gt;
&lt;br /&gt;
       Here’s a sample template file that we might create to build the output&lt;br /&gt;
       for this script.&lt;br /&gt;
&lt;br /&gt;
       $src/userinfo.html:&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE header&lt;br /&gt;
              title = 'Template Toolkit CGI Test'&lt;br /&gt;
           %]&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;a href=&amp;quot;mailto:[% email %]&amp;quot;&amp;gt;Email [% me.name %]&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;p&amp;gt;This is version [% version %]&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;h3&amp;gt;Projects&amp;lt;/h3&amp;gt;&lt;br /&gt;
           &amp;lt;ul&amp;gt;&lt;br /&gt;
           [% FOREACH project IN worklist(me.id) %]&lt;br /&gt;
              &amp;lt;li&amp;gt; &amp;lt;a href=&amp;quot;[% project.url %]&amp;quot;&amp;gt;[% project.name %]&amp;lt;/a&amp;gt;&lt;br /&gt;
           [% END %]&lt;br /&gt;
           &amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE footer %]&lt;br /&gt;
&lt;br /&gt;
       This example shows how we’ve separated the Perl implementation (code)&lt;br /&gt;
       from the presentation (HTML). This not only makes them easier to&lt;br /&gt;
       maintain in isolation, but also allows the re-use of existing template&lt;br /&gt;
       elements such as headers and footers, etc. By using template to create&lt;br /&gt;
       the output of your CGI scripts, you can give them the same consistency&lt;br /&gt;
       as your static pages built via ttree or other means.&lt;br /&gt;
&lt;br /&gt;
       Furthermore, we can modify our script so that it processes any one of a&lt;br /&gt;
       number of different templates based on some condition.  A CGI script to&lt;br /&gt;
       maintain a user database, for example, might process one template to&lt;br /&gt;
       provide an empty form for new users, the same form with some default&lt;br /&gt;
       values set for updating an existing user record, a third template for&lt;br /&gt;
       listing all users in the system, and so on.  You can use any Perl&lt;br /&gt;
       functionality you care to write to implement the logic of your&lt;br /&gt;
       application and then choose one or other template to generate the&lt;br /&gt;
       desired output for the application state.&lt;br /&gt;
&lt;br /&gt;
Dynamic Content Generation Via Apache/Mod_Perl Handler&lt;br /&gt;
       NOTE: the Apache::Template module is available from CPAN and provides a&lt;br /&gt;
       simple and easy to use Apache/mod_perl interface to the Template&lt;br /&gt;
       Toolkit.  Although basic, it implements most, if not all of what is&lt;br /&gt;
       described below, and it avoids the need to write your own handler.&lt;br /&gt;
       However, in many cases, you’ll want to write your own handler to&lt;br /&gt;
       customise processing for your own need, and this section will show you&lt;br /&gt;
       how to get started.&lt;br /&gt;
&lt;br /&gt;
       The Template module can be used from an Apache/mod_perl handler. Here’s&lt;br /&gt;
       an example of a typical Apache httpd.conf file:&lt;br /&gt;
&lt;br /&gt;
           PerlModule CGI;&lt;br /&gt;
           PerlModule Template&lt;br /&gt;
           PerlModule MyOrg::Apache::User&lt;br /&gt;
&lt;br /&gt;
           PerlSetVar websrc_root   /home/abw/websrc&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;Location /user/bin&amp;gt;&lt;br /&gt;
               SetHandler     perl-script&lt;br /&gt;
               PerlHandler    MyOrg::Apache::User&lt;br /&gt;
           &amp;lt;/Location&amp;gt;&lt;br /&gt;
&lt;br /&gt;
       This defines a location called &amp;quot;/user/bin&amp;quot; to which all requests will&lt;br /&gt;
       be forwarded to the &amp;quot;handler()&amp;quot; method of the &amp;quot;MyOrg::Apache::User&amp;quot;&lt;br /&gt;
       module.  That module might look something like this:&lt;br /&gt;
&lt;br /&gt;
           package MyOrg::Apache::User;&lt;br /&gt;
&lt;br /&gt;
           use strict;&lt;br /&gt;
           use vars qw( $VERSION );&lt;br /&gt;
           use Apache::Constants qw( :common );&lt;br /&gt;
           use Template qw( :template );&lt;br /&gt;
           use CGI;&lt;br /&gt;
&lt;br /&gt;
           $VERSION = 1.59;&lt;br /&gt;
&lt;br /&gt;
           sub handler {&lt;br /&gt;
               my $r = shift;&lt;br /&gt;
&lt;br /&gt;
               my $websrc = $r-&amp;gt;dir_config('websrc_root')&lt;br /&gt;
                   or return fail($r, SERVER_ERROR,&lt;br /&gt;
                                  &amp;quot;'websrc_root' not specified&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
               my $template = Template-&amp;gt;new({&lt;br /&gt;
                   INCLUDE_PATH  =&amp;gt; &amp;quot;$websrc/src/user:$websrc/lib&amp;quot;,&lt;br /&gt;
                   PRE_PROCESS   =&amp;gt; 'config',&lt;br /&gt;
                   OUTPUT        =&amp;gt; $r,     # direct output to Apache request&lt;br /&gt;
               });&lt;br /&gt;
&lt;br /&gt;
               my $params = {&lt;br /&gt;
                   uri     =&amp;gt; $r-&amp;gt;uri,&lt;br /&gt;
                   cgi     =&amp;gt; CGI-&amp;gt;new,&lt;br /&gt;
               };&lt;br /&gt;
&lt;br /&gt;
               # use the path_info to determine which template file to process&lt;br /&gt;
               my $file = $r-&amp;gt;path_info;&lt;br /&gt;
               $file =~ s[^/][];&lt;br /&gt;
&lt;br /&gt;
               $r-&amp;gt;content_type('text/html');&lt;br /&gt;
               $r-&amp;gt;send_http_header;&lt;br /&gt;
&lt;br /&gt;
               $template-&amp;gt;process($file, $params)&lt;br /&gt;
                   || return fail($r, SERVER_ERROR, $template-&amp;gt;error());&lt;br /&gt;
&lt;br /&gt;
               return OK;&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           sub fail {&lt;br /&gt;
               my ($r, $status, $message) = @_;&lt;br /&gt;
               $r-&amp;gt;log_reason($message, $r-&amp;gt;filename);&lt;br /&gt;
               return $status;&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       The handler accepts the request and uses it to determine the&lt;br /&gt;
       &amp;quot;websrc_root&amp;quot; value from the config file.  This is then used to define&lt;br /&gt;
       an &amp;quot;INCLUDE_PATH&amp;quot; for a new Template object.  The URI is extracted from&lt;br /&gt;
       the request and a CGI object is created.  These are both defined as&lt;br /&gt;
       template variables.&lt;br /&gt;
&lt;br /&gt;
       The name of the template file itself is taken from the &amp;quot;PATH_INFO&amp;quot;&lt;br /&gt;
       element of the request.  In this case, it would comprise the part of&lt;br /&gt;
       the URL coming after &amp;quot;/user/bin&amp;quot;,  e.g for &amp;quot;/user/bin/edit&amp;quot;, the&lt;br /&gt;
       template file would be &amp;quot;edit&amp;quot; located in &amp;quot;$websrc/src/user&amp;quot;.  The&lt;br /&gt;
       headers are sent and the template file is processed.  All output is&lt;br /&gt;
       sent directly to the &amp;quot;print()&amp;quot; method of the Apache request object.&lt;br /&gt;
&lt;br /&gt;
Using Plugins to Extend Functionality&lt;br /&gt;
       As we’ve already shown, it is possible to bind Perl data and functions&lt;br /&gt;
       to template variables when creating dynamic content via a CGI script or&lt;br /&gt;
       Apache/mod_perl process.  The Template Toolkit also supports a plugin&lt;br /&gt;
       interface which allows you define such additional data and/or&lt;br /&gt;
       functionality in a separate module and then load and use it as required&lt;br /&gt;
       with the &amp;quot;USE&amp;quot; directive.&lt;br /&gt;
&lt;br /&gt;
       The main benefit to this approach is that you can load the extension&lt;br /&gt;
       into any template document, even those that are processed &amp;quot;statically&amp;quot;&lt;br /&gt;
       by &amp;quot;tpage&amp;quot; or &amp;quot;ttree&amp;quot;.  You don’t need to write a Perl wrapper to&lt;br /&gt;
       explicitly load the module and make it available via the stash.&lt;br /&gt;
&lt;br /&gt;
       Let’s demonstrate this principle using the &amp;quot;DBI&amp;quot; plugin written by&lt;br /&gt;
       Simon Matthews (available from CPAN). You can create this template in&lt;br /&gt;
       your &amp;quot;src&amp;quot; directory and process it using &amp;quot;ttree&amp;quot; to see the results.&lt;br /&gt;
       Of course, this example relies on the existence of the appropriate SQL&lt;br /&gt;
       database but you should be able to adapt it to your own resources, or&lt;br /&gt;
       at least use it as a demonstrative example of what’s possible.&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE header&lt;br /&gt;
                title = 'User Info'&lt;br /&gt;
           %]&lt;br /&gt;
&lt;br /&gt;
           [% USE DBI('dbi:mSQL:mydbname') %]&lt;br /&gt;
&lt;br /&gt;
           &amp;lt;table border=0 width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
             &amp;lt;tr&amp;gt;&lt;br /&gt;
               &amp;lt;th&amp;gt;User ID&amp;lt;/th&amp;gt;&lt;br /&gt;
               &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;&lt;br /&gt;
               &amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&lt;br /&gt;
             &amp;lt;/tr&amp;gt;&lt;br /&gt;
           [% FOREACH user IN DBI.query('SELECT * FROM user ORDER BY id') %]&lt;br /&gt;
             &amp;lt;tr&amp;gt;&lt;br /&gt;
               &amp;lt;td&amp;gt;[% user.id %]&amp;lt;/td&amp;gt;&lt;br /&gt;
               &amp;lt;td&amp;gt;[% user.name %]&amp;lt;/td&amp;gt;&lt;br /&gt;
               &amp;lt;td&amp;gt;[% user.email %]&amp;lt;/td&amp;gt;&lt;br /&gt;
             &amp;lt;/tr&amp;gt;&lt;br /&gt;
           [% END %]&lt;br /&gt;
           &amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE footer %]&lt;br /&gt;
&lt;br /&gt;
       A plugin is simply a Perl module in a known location and conforming to&lt;br /&gt;
       a known standard such that the Template Toolkit can find and load it&lt;br /&gt;
       automatically.  You can create your own plugin by inheriting from the&lt;br /&gt;
       Template::Plugin module.&lt;br /&gt;
&lt;br /&gt;
       Here’s an example which defines some data items (&amp;quot;foo&amp;quot; and &amp;quot;people&amp;quot;)&lt;br /&gt;
       and also an object method (&amp;quot;bar&amp;quot;).  We’ll call the plugin &amp;quot;FooBar&amp;quot; for&lt;br /&gt;
       want of a better name and create it in the&lt;br /&gt;
       &amp;quot;MyOrg::Template::Plugin::FooBar&amp;quot; package.  We’ve added a &amp;quot;MyOrg&amp;quot; to&lt;br /&gt;
       the regular &amp;quot;Template::Plugin::*&amp;quot; package to avoid any conflict with&lt;br /&gt;
       existing plugins.&lt;br /&gt;
&lt;br /&gt;
           package MyOrg::Template::Plugin::FooBar;&lt;br /&gt;
           use base 'Template::Plugin'&lt;br /&gt;
           our $VERSION = 1.23;&lt;br /&gt;
&lt;br /&gt;
           sub new {&lt;br /&gt;
               my ($class, $context, @params) = @_;&lt;br /&gt;
&lt;br /&gt;
               bless {&lt;br /&gt;
                   _CONTEXT =&amp;gt; $context,&lt;br /&gt;
                   foo      =&amp;gt; 25,&lt;br /&gt;
                   people   =&amp;gt; [ 'tom', 'dick', 'harry' ],&lt;br /&gt;
               }, $class;&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
           sub bar {&lt;br /&gt;
               my ($self, @params) = @_;&lt;br /&gt;
               # ...do something...&lt;br /&gt;
               return $some_value;&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
       The plugin constructor &amp;quot;new()&amp;quot; receives the class name as the first&lt;br /&gt;
       parameter, as is usual in Perl, followed by a reference to something&lt;br /&gt;
       called a Template::Context object. You don’t need to worry too much&lt;br /&gt;
       about this at the moment, other than to know that it’s the main&lt;br /&gt;
       processing object for the Template Toolkit. It provides access to the&lt;br /&gt;
       functionality of the processor and some plugins may need to communicate&lt;br /&gt;
       with it. We don’t at this stage, but we’ll save the reference anyway in&lt;br /&gt;
       the &amp;quot;_CONTEXT&amp;quot; member. The leading underscore is a convention which&lt;br /&gt;
       indicates that this item is private and the Template Toolkit won’t&lt;br /&gt;
       attempt to access this member. The other members defined, &amp;quot;foo&amp;quot; and&lt;br /&gt;
       &amp;quot;people&amp;quot; are regular data items which will be made available to&lt;br /&gt;
       templates using this plugin. Following the context reference are passed&lt;br /&gt;
       any additional parameters specified with the USE directive, such as the&lt;br /&gt;
       data source parameter, &amp;quot;dbi:mSQL:mydbname&amp;quot;, that we used in the earlier&lt;br /&gt;
       DBI example.&lt;br /&gt;
&lt;br /&gt;
       If you don’t or can’t install it to the regular place for your Perl&lt;br /&gt;
       modules (perhaps because you don’t have the required privileges) then&lt;br /&gt;
       you can set the PERL5LIB environment variable to specify another&lt;br /&gt;
       location.  If you’re using &amp;quot;ttree&amp;quot; then you can add the following line&lt;br /&gt;
       to your configuration file instead.&lt;br /&gt;
&lt;br /&gt;
       $HOME/.ttreerc:&lt;br /&gt;
&lt;br /&gt;
           perl5lib = /path/to/modules&lt;br /&gt;
&lt;br /&gt;
       One further configuration item must be added to inform the toolkit of&lt;br /&gt;
       the new package name we have adopted for our plugins:&lt;br /&gt;
&lt;br /&gt;
       $HOME/.ttreerc:&lt;br /&gt;
&lt;br /&gt;
           plugin_base = 'MyOrg::Template::Plugin'&lt;br /&gt;
&lt;br /&gt;
       If you’re writing Perl code to control the Template modules directly,&lt;br /&gt;
       then this value can be passed as a configuration parameter when you&lt;br /&gt;
       create the module.&lt;br /&gt;
&lt;br /&gt;
           use Template;&lt;br /&gt;
&lt;br /&gt;
           my $template = Template-&amp;gt;new({&lt;br /&gt;
               PLUGIN_BASE =&amp;gt; 'MyOrg::Template::Plugin'&lt;br /&gt;
           });&lt;br /&gt;
&lt;br /&gt;
       Now we can create a template which uses this plugin:&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE header&lt;br /&gt;
              title = 'FooBar Plugin Test'&lt;br /&gt;
           %]&lt;br /&gt;
&lt;br /&gt;
           [% USE FooBar %]&lt;br /&gt;
&lt;br /&gt;
           Some values available from this plugin:&lt;br /&gt;
             [% FooBar.foo %] [% FooBar.bar %]&lt;br /&gt;
&lt;br /&gt;
           The users defined in the 'people' list:&lt;br /&gt;
           [% FOREACH uid = FooBar.people %]&lt;br /&gt;
             * [% uid %]&lt;br /&gt;
           [% END %]&lt;br /&gt;
&lt;br /&gt;
           [% INCLUDE footer %]&lt;br /&gt;
&lt;br /&gt;
       The &amp;quot;foo&amp;quot;, &amp;quot;bar&amp;quot;, and &amp;quot;people&amp;quot; items of the FooBar plugin are&lt;br /&gt;
       automatically resolved to the appropriate data items or method calls on&lt;br /&gt;
       the underlying object.&lt;br /&gt;
&lt;br /&gt;
       Using this approach, it is possible to create application functionality&lt;br /&gt;
       in a single module which can then be loaded and used on demand in any&lt;br /&gt;
       template.  The simple interface between template directives and plugin&lt;br /&gt;
       objects allows complex, dynamic content to be built from a few simple&lt;br /&gt;
       template documents without knowing anything about the underlying&lt;br /&gt;
       implementation.&lt;br /&gt;
&lt;br /&gt;
AUTHOR&lt;br /&gt;
       Andy Wardley &amp;lt;abw@wardley.org&amp;gt; &amp;lt;http://wardley.org/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
COPYRIGHT&lt;br /&gt;
       Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.&lt;br /&gt;
&lt;br /&gt;
       This module is free software; you can redistribute it and/or modify it&lt;br /&gt;
       under the same terms as Perl itself.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
perl v5.10.1                      2013-07-23        Template::Tutorial::Web(3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>50.45.173.59</name></author>
	</entry>
</feed>