From bba6e3b00fb11c1b82a15e76941bc2eeedd511ab Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Mon, 28 Nov 2016 10:59:33 -0500 Subject: [PATCH] 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 --- wire/core/FileCompiler.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wire/core/FileCompiler.php b/wire/core/FileCompiler.php index 2cc880a4..9830f32e 100644 --- a/wire/core/FileCompiler.php +++ b/wire/core/FileCompiler.php @@ -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];