Call preprocessor hooks in void context during the scan pass.
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 9 Jan 2008 07:30:46 +0000 (02:30 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 9 Jan 2008 07:30:46 +0000 (02:30 -0500)
This allows the hook to determine if it's just scanning, and avoid expensive
operations.

IkiWiki.pm

index b0ac8bbb4a1457496294f0d9644f3399044af1ec..d001760a205864aad7ce78c6d799d06444ffbc2a 100644 (file)
@@ -723,12 +723,25 @@ sub preprocess ($$$;$$) { #{{{
                                        $command, $page, $preprocessing{$page}).
                                "]]";
                        }
-                       my $ret=$hooks{preprocess}{$command}{call}->(
-                               @params,
-                               page => $page,
-                               destpage => $destpage,
-                               preview => $preprocess_preview,
-                       );
+                       my $ret;
+                       if (! $scan) {
+                               $ret=$hooks{preprocess}{$command}{call}->(
+                                       @params,
+                                       page => $page,
+                                       destpage => $destpage,
+                                       preview => $preprocess_preview,
+                               );
+                       }
+                       else {
+                               # use void context during scan pass
+                               $hooks{preprocess}{$command}{call}->(
+                                       @params,
+                                       page => $page,
+                                       destpage => $destpage,
+                                       preview => $preprocess_preview,
+                               );
+                               $ret="";
+                       }
                        $preprocessing{$page}--;
                        return $ret;
                }