Template2
Template2 copied to clipboard
On Win32, template on INCLUDE_PATH not found when CWD is on different drive [rt.cpan.org #83331]
Migrated from rt.cpan.org#83331 (status was 'open')
Requestors:
Attachments:
From [email protected] on 2013-02-15 01:28:11:
In Windows, when there is a single, fully-qualified path on INCLUDE_PATH, a template will not be found if the current working directory is on a different drive.
REPRO SCENARIO:
- Save the attached files TEST.PL and TEST.TT to C:\XXX.
- Set the working directory to C:\XXX
- Run test.pl, which finds a template on an INCLUDE_PATH set to 'c:\xxx'. It works correctly and the very simple template output prints to the console.
- Change directory to another drive, i.e., drive D:. (A network drive, USB drive, or even a read-only CD drive will be just fine.)
- Run C:\XXX\test.pl.
WHAT I SAW: test.pl fails, printing the message file error - test.tt: not found
WHAT I EXPECTED TO SEE: test.tt executes successfully as it did when executed from the same drive as specified on the INCLUDE_PATH as in repro step 3.
NOTES: A) The documentation claims that even though colon is an include path separator, it understands Windows-syntax paths and a colon followed by a backslash is not interpreted as a path separator.
B) Adding DELIMITER=';' to the TT options provided a successful workaround.
Despite the workaround, the TT documentation goes to great lengths to describe that Windows paths are understood, so this should work (or else the documentation should be changed.)
HOST ENVIRONMENT: Template-Toolkit 2.24 on Perl 5.16.1 ActiveState build 1601 (TemplateToolkit 2.24 was downloaded from CPAN and compiled from source) on Windows (Windows XP SP 2 on 32-bit X86 dual CPU.)
test.pl
use strict;
use Template;
my %ttopts = ( INCLUDE_PATH => "c:\\xxx" );
my $tt = Template->new(\%ttopts) ||
die "$Template::Error\n";
$tt->process("test.tt", undef) ||
die $tt->error() . "\n";
#test.tt
Hello, world!
From [email protected] on 2014-12-29 22:42:13:
This bug still persists in version 2.26. The fix is incredibly simple. Just replace line 350 in Provider.pm with
$dlim = ($^O eq 'MSWin32') ? ':(?![\\\/])' : ':';
-- Sune Karlsson Professor of Statistics Handelshögskolan/Ãrebro University School of Business Ãrebro University, SE-70182 Ãrebro, Sweden Phone +46 19 301257 http://www.oru.se/hh/sune_karlsson http://econpapers.repec.org/RAS/pka1.htm
This is possibly the same bug (or at least fix) as #57