From 0b381516a0e7f3559fb697d98aa28e480c60b823 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 7 Aug 2011 15:33:45 -0400 Subject: [PATCH] [feature/template-engine] Create load_and_render to reduce code duplication. PHPBB3-9726 --- phpBB/includes/template/template.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index ad5581499d..c368fd2621 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -188,6 +188,18 @@ class phpbb_template return $result[0]; } + return $this->load_and_render($handle); + } + + /** + * Loads a template for $handle, compiling it if necessary, and + * renders the template. + * + * @param string $handle Template handle to render + * @return bool True on success, false on failure + */ + private function load_and_render($handle) + { $renderer = $this->_tpl_load($handle); if ($renderer) @@ -425,13 +437,7 @@ class phpbb_template { $this->locator->set_filenames(array($filename => $filename)); - $renderer = $this->_tpl_load($filename); - - if ($renderer) - { - $renderer->render($this->context, $this->get_lang()); - } - else + if (!$this->load_and_render($handle)) { // trigger_error cannot be used here, as the output already started echo 'template->_tpl_include(): Failed including ' . htmlspecialchars($handle) . "\n";