diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index afb8bbcea..f66bbabd4 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -344,22 +344,27 @@ class TemplateHandler */ private function _fetch($filename) { + // Import Context and lang as local variables. $__Context = Context::getAll(); $__Context->tpl_path = $this->path; - + global $lang; + + // Start the output buffer. $__ob_level_before_fetch = ob_get_level(); ob_start(); + // Include the compiled template. include $filename; + // Fetch contents of the output buffer until the buffer level is the same as before. $contents = ''; while (ob_get_level() > $__ob_level_before_fetch) { $contents .= ob_get_clean(); } - // insert template path comment tag - if(config('debug.enabled') && Rhymix\Framework\Debug::isEnabledForCurrentUser()) + // Insert template path comment tag. + if(config('debug.enabled') && Rhymix\Framework\Debug::isEnabledForCurrentUser() && !starts_with('web_path . $this->filename . ' -->' . PHP_EOL; $contents = sprintf($sign, 'start') . $contents . sprintf($sign, 'end'); @@ -979,14 +984,10 @@ class TemplateHandler } return preg_replace_callback('@(?' . $matches[1];