aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template/twig/node/includejs.php
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-07-02 11:02:55 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-07-02 11:07:12 -0500
commit59d13d0535ab3687725d36f2dbe2ee64de294df8 (patch)
treece81e5616430b47feec09547657e346f5317fa88 /phpBB/includes/template/twig/node/includejs.php
parent156d5c671fb9db28fbbdcacb974093c2c52b0f5b (diff)
downloadforums-59d13d0535ab3687725d36f2dbe2ee64de294df8.tar
forums-59d13d0535ab3687725d36f2dbe2ee64de294df8.tar.gz
forums-59d13d0535ab3687725d36f2dbe2ee64de294df8.tar.bz2
forums-59d13d0535ab3687725d36f2dbe2ee64de294df8.tar.xz
forums-59d13d0535ab3687725d36f2dbe2ee64de294df8.zip
[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
Diffstat (limited to 'phpBB/includes/template/twig/node/includejs.php')
-rw-r--r--phpBB/includes/template/twig/node/includejs.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/phpBB/includes/template/twig/node/includejs.php b/phpBB/includes/template/twig/node/includejs.php
index bba5d4ef91..91b24e8068 100644
--- a/phpBB/includes/template/twig/node/includejs.php
+++ b/phpBB/includes/template/twig/node/includejs.php
@@ -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")
;
}
}