[Templates-svn] r1074 - trunk/lib/Template

svn@template-toolkit.org svn@template-toolkit.org


Author: abw
Date: 2007-05-03 11:54:52 +0100 (Thu, 03 May 2007)
New Revision: 1074

Modified:
   trunk/lib/Template/Provider.pm
Log:
fixed Template::Provider to handle compile errors properly without defeating the NOTFOUND cache

Modified: trunk/lib/Template/Provider.pm
===================================================================
--- trunk/lib/Template/Provider.pm	2007-05-03 08:32:37 UTC (rev 1073)
+++ trunk/lib/Template/Provider.pm	2007-05-03 10:54:52 UTC (rev 1074)
@@ -469,20 +469,26 @@
         warn($self->error(), "\n");
     }
 
-    # Now fetch template from source, compile, and cache.
+    # load template from source
     my ($template, $error) = $self->_load($name, $t_name);
-    unless ($error) {
-        ($template, $error) = $self->_compile($template, $self->_compiled_filename($name) );
 
-        # Store compiled template and return it
-        return $self->store( $name, $template->{data} ) unless $error;
+    if ($error) {
+        # Template could not be fetched.  Add to the negative/notfound cache.
+        $self->{ NOTFOUND }->{ $name } = time;
+        return ( $template, $error );
     }
 
-    # Template could not be fetched.  Add to the negative/notfound cache.
-    $self->{ NOTFOUND }->{ $name } = time
-        unless $error;
+    # compile template source
+    ($template, $error) = $self->_compile($template, $self->_compiled_filename($name) );
 
-    return ( $template, $error );
+    if ($error) {
+        # return any compile time error
+        return ($template, $error);
+    }
+    else {
+        # Store compiled template and return it
+        return $self->store($name, $template->{data}) ;
+    }
 }