1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00

[feature/twig] INCLUDEJS behavior now supports local relative paths

This was done because T_TEMPLATE_PATH is not always correct for js files
(e.g. the inheriting style does not include these). Now we use the Twig
Loader to find the correct file to link to (most specific file first, then
parent styles). Also allows using @namespace convention

PHPBB3-11598
This commit is contained in:
Nathaniel Guse
2013-07-02 11:02:55 -05:00
parent 156d5c671f
commit 59d13d0535
9 changed files with 20 additions and 12 deletions

View File

@@ -31,9 +31,17 @@ class phpbb_template_twig_node_includejs extends Twig_Node
$config = $this->environment->get_phpbb_config();
$compiler
->write("\$context['definition']->append('SCRIPTS', '<script type=\"text/javascript\" src=\"' . ")
->write("\$js_file = ")
->subcompile($this->getNode('expr'))
->raw(" . '?assets_version=" . $config['assets_version'] . "\"></script>');\n")
->raw(";\n")
->write("if (!file_exists(\$js_file)) {\n")
->indent()
->write("\$js_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$js_file);\n")
->outdent()
->write("}\n")
->write("\$context['definition']->append('SCRIPTS', '<script type=\"text/javascript\" src=\"' . ")
->raw("\$js_file")
->raw(" . '?assets_version=" . $config['assets_version'] . "\"></script>\n');\n")
;
}
}