1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-30 11:11:23 +02:00

[feature/twig] Changing INCLUDEJS behavior

Was:
<!-- INCLUDEJS template/foo.js -->

Now:
<!-- INCLUDEJS T_TEMPLATE_PATH ~ '/foo.js' -->

Reasons for this:
1. INCLUDEJS is 3.1-dev only

2. INCLUDEJS has odd behavior to begin with (arbitrary setting root path
to styles/name/ directory)

3. INCLUDEJS could not include files from outside directories or anywhere
else

4. It was easier to change INCLUDEJS behavior to something more flexible
and useful than hack around it to make it work as it was with Twig.

PHPBB3-11598
This commit is contained in:
Nathan Guse 2013-06-24 13:32:31 -05:00
parent 63143a1a57
commit 1a0819bdc4
10 changed files with 15 additions and 14 deletions

View File

@ -32,15 +32,15 @@ class phpbb_template_twig_lexer extends Twig_Lexer
'UNDEFINE',
'ENDDEFINE',
/*'INCLUDE',
'INCLUDEPHP',
'INCLUDEJS',*/
'INCLUDEPHP',*/
'INCLUDEJS',
'PHP',
'ENDPHP',
'EVENT',
);
// Replace <!-- INCLUDE blah.html --> with {% include 'blah.html' %}
$code = preg_replace('#<!-- INCLUDE(PHP|JS)? (.*?) -->#', "{% INCLUDE$1 '$2' %}", $code);
$code = preg_replace('#<!-- INCLUDE(PHP)? (.*?) -->#', "{% INCLUDE$1 '$2' %}", $code);
// This strips the $ inside of a tag directly after the token, which was used in <!-- DEFINE $NAME
$code = preg_replace('#<!-- DEFINE \$(.*)-->#', '<!-- DEFINE $1-->', $code);

View File

@ -24,8 +24,9 @@ class phpbb_template_twig_node_includejs extends Twig_Node
$compiler->addDebugInfo($this);
$compiler
->write("\$context['SCRIPTS'] .= '<script type=\"text/javascript\" src=")
->write("\$context['SCRIPTS'] .= '<script type=\"text/javascript\" src=\"' . ")
->subcompile($this->getNode('expr'))
->raw(">';\n\n");
->raw(" . '\">';\n\n")
;
}
}

View File

@ -38,7 +38,7 @@ function insert_single(user)
// ]]>
</script>
<!-- ENDIF -->
<!-- INCLUDEJS template/forum_fn.js -->
<!-- INCLUDEJS T_TEMPLATE_PATH ~ '/forum_fn.js' -->
<h2 class="solo">{L_FIND_USERNAME}</h2>
<form method="post" action="{S_MODE_ACTION}" id="search_memberlist">

View File

@ -55,7 +55,7 @@
<!-- 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_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 template/ajax.js -->
<!-- INCLUDEJS T_TEMPLATE_PATH ~ '/ajax.js' -->
{SCRIPTS}
<!-- EVENT overall_footer_after -->

View File

@ -39,7 +39,7 @@
{
dE('colour_palette');
e = document.getElementById('colour_palette');
if (e.style.display == 'block')
{
document.getElementById('bbpalette').value = '{LA_FONT_COLOR_HIDE}';
@ -52,7 +52,7 @@
// ]]>
</script>
<!-- INCLUDEJS template/editor.js -->
<!-- INCLUDEJS T_TEMPLATE_PATH ~ '/editor.js' -->
<!-- IF S_BBCODE_ALLOWED -->
<div id="colour_palette" style="display: none;">

View File

@ -15,6 +15,6 @@
{S_TZ_OPTIONS}
</select>
<!-- INCLUDEJS template/timezone.js -->
<!-- INCLUDEJS T_TEMPLATE_PATH ~ '/timezone.js' -->
</dd>
</dl>

View File

@ -47,4 +47,4 @@
</div>
</div>
<!-- INCLUDEJS template/avatars.js -->
<!-- INCLUDEJS T_TEMPLATE_PATH ~ '/avatars.js' -->

View File

@ -15,6 +15,6 @@
{S_TZ_OPTIONS}
</select>
<!-- INCLUDEJS template/timezone.js -->
<!-- INCLUDEJS T_TEMPLATE_PATH ~ '/timezone.js' -->
</td>
</tr>

View File

@ -95,7 +95,7 @@
</tr>
</table>
<!-- INCLUDEJS template/avatars.js -->
<!-- INCLUDEJS T_TEMPLATE_PATH ~ '/avatars.js' -->
<!-- ELSEIF S_LIST -->

View File

@ -48,6 +48,6 @@
</tr>
</table>
<!-- INCLUDEJS template/avatars.js -->
<!-- INCLUDEJS T_TEMPLATE_PATH ~ '/avatars.js' -->
<!-- INCLUDE ucp_footer.html -->