This is the tail end of a perl subroutine in which I’ve experimented in defining $path with limited success. I’ve commented out all the experimental lines, though the first two work just fine. The third line works in the action of a form and in links, as Kevin helpfully explained above; but it does not work when passed to Template Toolkit (TT).
I know that TT doesn’t require an absolute address, since the two lines starting with usr below are taken from the TT book. The tilde is just something I saw in another book.
Either I’m wrong in assuming that /www is sufficient to define a path relative to the top of my FQ website, or TT is picky about how I give it information.
I’m sure I’m making a simple blunder, but I’m not a computer professional, and I get confused often. Any advice will be appreciated; thanks!
Code:
# Call Template Toolkit
local $| = 1; # auto flush buffer
# my $path = '/big/dom/xexploringmyself/www/templates'; # works
# my $path = '/big/dom/x'. $server .'/www/templates'; # works
# my $path = '/www/templates'; # works in form action and links, but fails here
# my $path = './www/templates'; # fails
# my $path = '../www/templates'; # fails
# my $path = 'www/templates'; # fails
# my $path = 'usr/local/www/templates'; # fails
# my $path = 'usr/www/templates'; # fails
# my $path = '~/www/templates'; # fails
my $tt = Template->new(
{INCLUDE_PATH => "$path"}
);
my $input = 'open_courses.html';
my $vars = {
student_id => $student_id,
name_full => $student_info_hash{name_full},
courses => \%row_data
};
print "Content-Type: text/html\n\n";
$tt->process($input, $vars)
or die $tt->error();
}