Do not render script methods when no script present, adcd0eb9 followup

This commit is contained in:
Stephen Abello
2023-04-18 14:57:06 +02:00
parent 51617113eb
commit 41b4ef357f

View File

@@ -2,6 +2,7 @@
{# @license http://opensource.org/licenses/AGPL-3.0 #}
{% apply spaceless %}
{% set sId = oLayout.GetId() | sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) %}
{% set bHasOnInitOrOnDomReadyScripts = aPage.aJsInlineOnInit is not empty or aPage.aJsInlineOnDomReady is not empty %}
{% if bEscapeContent %}
{{ render_block(oLayout, {aPage: aPage})|escape }}
{% else %}
@@ -25,19 +26,21 @@
</script>
{% endfor %}
{% endblock %}
<script type="text/javascript">
let fOnJsFilesLoaded{{ sId }} = function (fResolve) {
{% for sJsInline in aPage.aJsInlineOnInit %}
{{ sJsInline|raw }}
{% endfor %}
{% for sJsInline in aPage.aJsInlineOnDomReady %}
{{ sJsInline|raw }}
{% endfor %}
fResolve();
}
</script>
{% if bHasOnInitOrOnDomReadyScripts %}
<script type="text/javascript">
let fOnJsFilesLoaded{{ sId }} = function (fResolve) {
{% for sJsInline in aPage.aJsInlineOnInit %}
{{ sJsInline|raw }}
{% endfor %}
{% for sJsInline in aPage.aJsInlineOnDomReady %}
{{ sJsInline|raw }}
{% endfor %}
fResolve();
}
</script>
{% endif %}
{% set sPromiseId = aPage.sPromiseId %}
{% if aPage.aJsFiles is not empty %}
@@ -132,13 +135,15 @@
</script>
{% endblock %}
{% else %}
{% block iboPageJsInlineOnDomReady %}
<script type="text/javascript">
window['{{ sPromiseId }}'] = new Promise(function (fNoJsFileResolve, fNoJsFileReject) {
fOnJsFilesLoaded{{ sId }}(fNoJsFileResolve);
});
</script>
{% endblock %}
{% if bHasOnInitOrOnDomReadyScripts %}
{% block iboPageJsInlineOnDomReady %}
<script type="text/javascript">
window['{{ sPromiseId }}'] = new Promise(function (fNoJsFileResolve, fNoJsFileReject) {
fOnJsFilesLoaded{{ sId }}(fNoJsFileResolve);
});
</script>
{% endblock %}
{% endif %}
{% endif %}
{% if aDeferredBlocks is not empty %}