From 530cad6cc8f697e8ae3118bef96ade94bc5c29b4 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Fri, 5 Apr 2019 18:40:48 -0500 Subject: [PATCH] Switch from eval() to include() in template class. APC caches includes nowadays so caching is not necessary any more. --- lib/Template.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/Template.php b/lib/Template.php index 17c16e69..12eb3c1c 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -3,25 +3,15 @@ use function Safe\file_get_contents; use function Safe\ob_end_clean; class Template{ - protected static $Cache = []; - protected static function Get(string $templateName, array $arguments = []): string{ - // Expand the passed variables - // Use these funny names so that we can use 'name' and 'value' as template variables + // Expand the passed variables to make them available to the included template. + // We use these funny names so that we can use 'name' and 'value' as template variables if we want to. foreach($arguments as $innerName => $innerValue){ $$innerName = $innerValue; } - if(array_key_exists($templateName, self::$Cache)){ - $fileContents = self::$Cache[$templateName]; - } - else{ - $fileContents = file_get_contents(TEMPLATES_PATH . '/' . $templateName . '.php'); - self::$Cache[$templateName] = $fileContents; - } - ob_start(); - eval(' ?>' . $fileContents . '