From ddaccaf63e8ae7ff5bd13b187fa40f3d089f02f0 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 1 Jul 2013 11:52:03 -0500 Subject: [PATCH] [feature/twig] A bit of cleanup in twig.php PHPBB3-11598 --- phpBB/includes/template/twig/twig.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index 717213ea1f..5fe8ba97f6 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -266,7 +266,7 @@ class phpbb_template_twig implements phpbb_template } $context = &$this->get_template_vars(); - $this->twig->display($this->filenames[$handle], $context); + $this->twig->display($this->get_filename_from_handle($handle), $context); return true; } @@ -324,20 +324,12 @@ class phpbb_template_twig implements phpbb_template */ public function assign_display($handle, $template_var = '', $return_content = true) { - ob_start(); - $result = $this->display($handle); - $contents = ob_get_clean(); - if ($result === false) - { - return false; - } - if ($return_content) { - return $contents; + return $this->twig->render($this->get_filename_from_handle($handle)); } - $this->assign_var($template_var, $contents); + $this->assign_var($template_var, $this->twig->render($this->get_filename_from_handle($handle))); return true; } @@ -448,4 +440,15 @@ class phpbb_template_twig implements phpbb_template return $vars; } + + /** + * Get a filename from the handle + * + * @param string $handle + * @return string + */ + protected function get_filename_from_handle($handle) + { + return (isset($this->filenames[$handle])) ? $this->filenames[$handle] : $handle; + } }