I am using the template example in the Perl Cookbook to dynamically generate pages. I have looked into Template::Toolkit, but I'm uncertain whether or not it will be available on the server my Perl code is to run on.
The template example in the Perl Cookbook should be more than sufficient. My dilemma, however, is determining the best way to use it. I am going along with using %%ABC%% placeholders to swap out things generated by my Perl code. My goal is to keep ALL HTML code out of my Perl script so that any design modifications can be done via the external template files.
My current setup is to have two template files for a single page. The first template page contains all of the HTML code to create the bulk of the page and two placeholders, %%PAGETITLE%% and %%MAIN%%. %%MAIN%% is the placeholder for the page content.
[html]
[body]
[table]
[tr]
[td]
[table]
%%MAIN%%
[/table]
[/td]
[/tr]
[/table]
[/body]
[/html]
The second template file would contain how the contents of that page should be formatted. This should only consist of
[tr] and [td]tags.
[tr]
[td]%%VAL1%%[/td]
[td]%%VAL2%%[/td]
[td]%%VAL3%%[/td]
[/tr]
So, my Perl code would fill in the placeholders of the second template file. Grab that, and stick it in the first template file as the %%MAIN%% placeholder.
Hopefully this makes sense. Is this a good approach? Any better suggestions for keeping all HTML code out of my Perl script?