Sometimes we have to make websites for clients that don't know how to use the web.
Usually there is a certain section of their website that
must be updated often. For those spots, I use this script.
This script relies on ePerl for the templates.
In the directory with the script, I have a file called config.pl:
$config = {
'parents' => {
file => 'data/parents.pl',
name => "Parent Link",
},
'highlights' => {
file => 'data/highlights.pl',
name => 'Issue Highlights',
input => "input/highlights.tmpl",
output => 'output/highlights.tmpl',
},
'financial' => {
file => 'data/financial.pl',
name => 'Financial / Public',
}
};
Each section of this hash is for a file that the client needs to change. The sections specify where to store
the data that is plugged into the template, a descriptive name, and which ePerl template to use.
My input/default.tmpl looks like:
<html>
<body>
<form method="POST">
<input type="hidden" name="file" value="<:= $::file :>">
<input type="hidden" name="action" value="save">
<textarea name="body" cols="70" rows="50" wrap="physical"><:=$body:></
+textarea>
<br>
<input type="submit" value="Save Changes">
</form>
</body>
</html>
My output/default.tmpl is below. I made a function in main to convert linebreaks into <br> and <p> tags.
<:= main::encode($body) :>
I can either use this script to generate pieces of webpages or entire webpages. Examples:
<!--#include virtual="/cgi-bin/template/admin.pl?file=parents" -->
|