mirror of
https://github.com/processwire/processwire.git
synced 2025-08-15 19:24:28 +02:00
Add option to exclude FileCompiler at include() time by specifying include(/*NoCompile*/'filename.php');
or include('filename.php'/*NoCompile*/);
. The include() can also be include_once(), require(), require_once(), wireRenderFile(), wireIncludeFile() or new TemplateFile(). Relevent to PR #13
This commit is contained in:
@@ -429,6 +429,11 @@ class FileCompiler extends Wire {
|
||||
}
|
||||
}
|
||||
|
||||
if(stripos($data, "FileCompiler=?") !== false) {
|
||||
// Allow for a token that gets replaced so a file can detect if it's compiled
|
||||
$data = str_replace("FileCompiler=?", "FileCompiler=Yes", $data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -538,6 +543,11 @@ class FileCompiler extends Wire {
|
||||
if(!preg_match_all($re, $data, $matches)) return;
|
||||
|
||||
foreach($matches[0] as $key => $fullMatch) {
|
||||
|
||||
// if the include statement looks like one of these below then skip compilation for included file
|
||||
// include(/*NoCompile*/__DIR__ . '/file.php');
|
||||
// include(__DIR__ . '/file.php'/*NoCompile*/);
|
||||
if(strpos($fullMatch, 'NoCompile') !== false) continue;
|
||||
|
||||
$open = $matches[1][$key];
|
||||
$funcMatch = $matches[2][$key];
|
||||
|
Reference in New Issue
Block a user