From 41b4ef357f5ba634edcbfc450d4c955f6f499c39 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Tue, 18 Apr 2023 14:57:06 +0200 Subject: [PATCH] Do not render script methods when no script present, adcd0eb9 followup --- .../backoffice/ajaxpage/layout.html.twig | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/templates/pages/backoffice/ajaxpage/layout.html.twig b/templates/pages/backoffice/ajaxpage/layout.html.twig index 00c9db5179..0d2c754b06 100644 --- a/templates/pages/backoffice/ajaxpage/layout.html.twig +++ b/templates/pages/backoffice/ajaxpage/layout.html.twig @@ -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 @@ {% endfor %} {% endblock %} - - + {% if bHasOnInitOrOnDomReadyScripts %} + + {% endif %} {% set sPromiseId = aPage.sPromiseId %} {% if aPage.aJsFiles is not empty %} @@ -132,13 +135,15 @@ {% endblock %} {% else %} - {% block iboPageJsInlineOnDomReady %} - - {% endblock %} + {% if bHasOnInitOrOnDomReadyScripts %} + {% block iboPageJsInlineOnDomReady %} + + {% endblock %} + {% endif %} {% endif %} {% if aDeferredBlocks is not empty %}