mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[feature/template-engine] Create load_and_render to reduce code duplication.
PHPBB3-9726
This commit is contained in:
parent
52f208900f
commit
0b381516a0
1 changed files with 13 additions and 7 deletions
|
@ -188,6 +188,18 @@ class phpbb_template
|
||||||
return $result[0];
|
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);
|
$renderer = $this->_tpl_load($handle);
|
||||||
|
|
||||||
if ($renderer)
|
if ($renderer)
|
||||||
|
@ -425,13 +437,7 @@ class phpbb_template
|
||||||
{
|
{
|
||||||
$this->locator->set_filenames(array($filename => $filename));
|
$this->locator->set_filenames(array($filename => $filename));
|
||||||
|
|
||||||
$renderer = $this->_tpl_load($filename);
|
if (!$this->load_and_render($handle))
|
||||||
|
|
||||||
if ($renderer)
|
|
||||||
{
|
|
||||||
$renderer->render($this->context, $this->get_lang());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// trigger_error cannot be used here, as the output already started
|
// trigger_error cannot be used here, as the output already started
|
||||||
echo 'template->_tpl_include(): Failed including ' . htmlspecialchars($handle) . "\n";
|
echo 'template->_tpl_include(): Failed including ' . htmlspecialchars($handle) . "\n";
|
||||||
|
|
Loading…
Add table
Reference in a new issue