/** * Loads up the file located at $templateFilePath, assigns it $variables * and saves the generated HTML. * @param string $templateFilePath * @param array $variables * @param boolean $allowDebug * @return string */ public static function parseFile($templateFilePath, $variables = array(), $allowDebug = true) { ob_start(); // Print debug info in the the logs // only when Strata is running as the development // environment. if (Strata::isDev() && $allowDebug) { $app = Strata::app(); $startedAt = microtime(true); // Print in the html as a comment $partialFilePath = defined('ABSPATH') ? str_replace(dirname(dirname(ABSPATH)), "", $templateFilePath) : $templateFilePath; } extract($variables); include $templateFilePath; if (Strata::isDev() && $allowDebug) { $executionTime = microtime(true) - $startedAt; $timer = sprintf(" (Done in %s seconds)", round($executionTime, 4)); $app->log($partialFilePath . $timer, "<yellow>Template</yellow>"); } return ob_get_clean(); }
private function shouldBeDebugging() { return $this->useStrataDebugger() && Strata::isDev() && !Strata::isCommandLineInterface(); }