diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-07-06 16:26:56 -0500 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-07-06 16:26:56 -0500 |
commit | 0894a1377013965657f29a42202a630ba83daf95 (patch) | |
tree | cb535e42ce4fed055847d8cc7ba8c340484340f7 | |
parent | 921d44aa4dfa307eb3b7e4f24befabb07e727812 (diff) | |
download | forums-0894a1377013965657f29a42202a630ba83daf95.tar forums-0894a1377013965657f29a42202a630ba83daf95.tar.gz forums-0894a1377013965657f29a42202a630ba83daf95.tar.bz2 forums-0894a1377013965657f29a42202a630ba83daf95.tar.xz forums-0894a1377013965657f29a42202a630ba83daf95.zip |
[feature/twig] If DEBUG, EVENT will always look for new/missing tpl event files
If debug mode is enabled, lets check for new/removed EVENT templates on
page load rather than at compile. This is slower, but makes developing
extensions easier (no need to purge the cache when a new event template
file is added)
PHPBB3-11598
-rw-r--r-- | phpBB/includes/template/twig/node/event.php | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/phpBB/includes/template/twig/node/event.php b/phpBB/includes/template/twig/node/event.php index 984ba35244..971dea14fa 100644 --- a/phpBB/includes/template/twig/node/event.php +++ b/phpBB/includes/template/twig/node/event.php @@ -43,17 +43,37 @@ class phpbb_template_twig_node_event extends Twig_Node { $ext_namespace = str_replace('/', '_', $ext_namespace); - if ($this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) + if (defined('DEBUG')) + { + // If debug mode is enabled, lets check for new/removed EVENT + // templates on page load rather than at compile. This is + // slower, but makes developing extensions easier (no need to + // purge the cache when a new event template file is added) + $compiler + ->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n") + ->indent() + ; + } + + if (defined('DEBUG') || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) { $compiler ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") // We set the namespace lookup order to be this extension first, then the main path - ->write("\$this->env->setNamespaceLookUpOrder(array('" . $ext_namespace . "', '__main__'));\n") - ->write("\$this->env->loadTemplate('@" . $ext_namespace . "/" . $location . ".html')->display(\$context);\n") + ->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n") + ->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n") ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") ; } + + if (defined('DEBUG')) + { + $compiler + ->outdent() + ->write("}\n\n") + ; + } } } } |