mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/twig] INCLUDEJS now uses the definition class
This had to be done because, like DEFINE, setting variables to $context only affected the local file and any children, not parent templates. PHPBB3-11598
This commit is contained in:
parent
883b0a9f8c
commit
156d5c671f
4 changed files with 23 additions and 4 deletions
|
@ -47,4 +47,23 @@ class phpbb_template_twig_definition
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append to a variable
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @return phpbb_template_twig_definition
|
||||
*/
|
||||
public function append($name, $value)
|
||||
{
|
||||
if (!isset($this->definitions[$name]))
|
||||
{
|
||||
$this->definitions[$name] = '';
|
||||
}
|
||||
|
||||
$this->definitions[$name] .= $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ class phpbb_template_twig_node_includejs extends Twig_Node
|
|||
$config = $this->environment->get_phpbb_config();
|
||||
|
||||
$compiler
|
||||
->write("\$context['SCRIPTS'] .= '<script type=\"text/javascript\" src=\"' . ")
|
||||
->write("\$context['definition']->append('SCRIPTS', '<script type=\"text/javascript\" src=\"' . ")
|
||||
->subcompile($this->getNode('expr'))
|
||||
->raw(" . '?assets_version=" . $config['assets_version'] . "\"></script>';\n\n")
|
||||
->raw(" . '?assets_version=" . $config['assets_version'] . "\"></script>');\n")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/forum_fn.js?assets_version={T_ASSETS_VERSION}"></script>
|
||||
<script type="text/javascript" src="{T_ASSETS_PATH}/javascript/core.js?assets_version={T_ASSETS_VERSION}"></script>
|
||||
<!-- INCLUDEJS {T_TEMPLATE_PATH}/ajax.js -->
|
||||
{SCRIPTS}
|
||||
{$SCRIPTS}
|
||||
|
||||
<!-- EVENT overall_footer_after -->
|
||||
</body>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<script type="text/javascript" src="{T_JQUERY_LINK}"></script>
|
||||
<!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js?assets_version={T_ASSETS_VERSION}" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF -->
|
||||
<script type="text/javascript" src="{T_ASSETS_PATH}/javascript/core.js?assets_version={T_ASSETS_VERSION}"></script>
|
||||
{SCRIPTS}
|
||||
{$SCRIPTS}
|
||||
|
||||
<!-- EVENT overall_footer_after -->
|
||||
</body>
|
||||
|
|
Loading…
Add table
Reference in a new issue