]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 288527 - change precompilation to use Bugzilla::Template and so do it right....
authorgerv%gerv.net <>
Tue, 5 Apr 2005 05:29:07 +0000 (05:29 +0000)
committergerv%gerv.net <>
Tue, 5 Apr 2005 05:29:07 +0000 (05:29 +0000)
Bugzilla/Template.pm
checksetup.pl

index 29ed2924c12a25d5d91c382ab5324a0b5267a904..23a9c0a7c9d8476e06f76a040a27ae4e02f5d085 100644 (file)
@@ -218,8 +218,7 @@ sub create {
 
         # Functions for processing text within templates in various ways.
         # IMPORTANT!  When adding a filter here that does not override a
-        # built-in filter, please also add a stub filter to checksetup.pl
-        # and t/004template.t.
+        # built-in filter, please also add a stub filter to t/004template.t.
         FILTERS => {
 
             # Render text in required style.
index c46bcfec9608df91e737ad8b061af0c4b3694978..0e2af16084354a46e41edf7dbabcd944cf2692c8 100755 (executable)
@@ -1201,9 +1201,9 @@ unless ($switch{'no_templates'}) {
         return if ($name !~ /\.tmpl$/);
         $name =~ s/\Q$::templatepath\E\///; # trim the bit we don't pass to TT
 
-        # Do this to avoid actually processing the templates
-        my ($data, $err) = $::provider->fetch($name);
-        die "Could not compile $name: " . $data . "\n" if $err;
+        # Compile the template but throw away the result. This has the side-
+        # effect of writing the compiled version to disk.
+        $::template->context()->template($name);
     }
     
     eval("use Template");
@@ -1212,46 +1212,13 @@ unless ($switch{'no_templates'}) {
         print "Precompiling templates ...\n" unless $silent;
 
         use File::Find;
-
+        require Bugzilla::Template;
+        
         # Don't hang on templates which use the CGI library
         eval("use CGI qw(-no_debug)");
-        foreach $::templatepath (@templatepaths) {
-           $::provider = Template::Provider->new(
-           {
-               # Directories containing templates.
-               INCLUDE_PATH => $::templatepath,
-
-               PRE_CHOMP => 1 ,
-               TRIM => 1 ,
-
-               # => $datadir/template/`pwd`/template/{en, ...}/{custom,default}
-               COMPILE_DIR => "$datadir/template",
-
-               # Initialize templates (f.e. by loading plugins like Hook).
-               PRE_PROCESS => "global/initialize.none.tmpl",
-
-               # These don't actually need to do anything here, just exist
-               FILTERS =>
-               {
-                inactive => sub { return $_; } ,
-                closed => sub { return $_; },
-                obsolete => sub { return $_; },
-                js => sub { return $_; },
-                html_linebreak => sub { return $_; },
-                no_break => sub { return $_; },
-                url_quote => sub { return $_; },
-                xml => sub { return $_; },
-                quoteUrls => sub { return $_; },
-                bug_link => [ sub { return sub { return $_; } }, 1],
-                csv => sub { return $_; },
-                unitconvert => sub { return $_; },
-                time => sub { return $_; },
-                wrap_comment => sub { return $_; },
-                none => sub { return $_; } ,
-               },
-           }) || die ("Could not create Template Provider: "
-                       . Template::Provider->error() . "\n");
+        $::template = Bugzilla::Template->create();
 
+        foreach $::templatepath (@templatepaths) {
            # Traverse the template hierarchy. 
            find({ wanted => \&compile, no_chdir => 1 }, $::templatepath);
        }