in reply to Learning Template::Toolkit - have I understood?
2. RE: ttree recursion vs. content recursion - From the tutorial suggested above, I note: DYNAMIC CONTENT GENERATION VIA CGI SCRIPT
Which I believe implies that although TT has ttree to automatically drill down through a hierarchy to find and process a whack of templates, if I have only one template and a whack of content files, I have to do the recursion work myself. To my mind, this seems a little backwards, since a large template-driven site is rarely going to be the first case, and much more commonly going to be the second case. No?#!/usr/bin/perl -w use strict; use Template; my $file = 'src/greeting.html'; my $vars = { message => "Hello World\n" }; my $template = Template->new(); $template->process($file, $vars) || die "Template process failed: ", $template->error(), "\n";
So, OK, I make my template with the appropriate INCLUDES, etc. Then I have to write a script that travels my website structure looking for content files (probably designated by an extension), and merging them with the template. To be honest, I could have done that myself with a couple of custom markers in the html files and a little routine to scour the pages for the markers, parse out the tag and shunt to a corresponding insertion routine. But I guess the moduloe has the advantage of lots of other functionality for the future...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Learning Template::Toolkit - have I understood?
by perrin (Chancellor) on Aug 30, 2006 at 17:07 UTC | |
|
Re^2: Learning Template::Toolkit - have I understood?
by Asim (Hermit) on Aug 30, 2006 at 14:57 UTC |