diff --git a/src/Template/Renderer.php b/src/Template/Renderer.php index 46584086..e38a6c9b 100644 --- a/src/Template/Renderer.php +++ b/src/Template/Renderer.php @@ -36,23 +36,17 @@ public function __construct(array $directories) * * @param string $template * @param array $data - * @param boolean $toString * @return string */ - public function render($template, array $data = [], $toString = false) + public function render($template, array $data = []) { $file = $this->getTemplate("$template.php"); // Extracts the specific parameters to the template. - if ($data) { + if ( ! empty($data)) { extract($data); } - // Buffers the file and get its output, else include the file - if ($toString) { - return $this->toString($file); - } - include $file; } @@ -87,27 +81,4 @@ private function getTemplate($template) return new InvalidArgumentException('Template file not found.'); } - - /** - * Returns the output to string. - * - * @param string $file - * @return string - */ - private function toString($file) - { - ob_start(); - - $fileContents = file_get_contents($file); - $removedTags = str_replace('/', '; ?>', $removedTags); - - echo eval('?>' . $result); - - $result = ob_get_contents(); - - ob_end_clean(); - - return $result; - } }