[Templates] Loading Compiled Templates from disk

Matthews Simon sam@knowledgepool.com
Mon, 7 Jan 2002 10:06:02 -0000


It would appear that the current version of Provider never re-uses templates
that 
have been compiled and placed on disk. The method _load_compiled is never
called.
The problem appears to be that the Provider is checking the mtime of the
source 
template against the compiled version with <.  However line 784 of Provider
uses
utime to ensure that the mtime of the compiled template is the same or older
than 
that of the source file.  The patch below changes the tests to check for <=.

Templates will only be re-compiled when the source file is newer than the
compiled
template.

SAM




Index: Provider.pm
===================================================================
RCS file: /template-toolkit/Template2/lib/Template/Provider.pm,v
retrieving revision 2.41
diff -r2.41 Provider.pm
355c355
< 	if ($compiled && -f $compiled && (stat($name))[9] <
(stat($compiled))[9]) {
---
> 	if ($compiled && -f $compiled && (stat($name))[9] <=
(stat($compiled))[9]) {
375c375
< 	if ($compiled && -f $compiled && (stat($name))[9] <
(stat($compiled))[9]) {
---
> 	if ($compiled && -f $compiled && (stat($name))[9] <=
(stat($compiled))[9]) {
444c444
< 		if ($compiled && -f $compiled && (stat($path))[9] <
(stat($compiled))[9]) {
---
> 		if ($compiled && -f $compiled && (stat($path))[9] <=
(stat($compiled))[9]) {