损坏的html脚本-封装是否更改html标签的位置?

问题描述 投票:0回答:1

我正在将Magento2与fpc,清漆,redis和Incapsula一起使用,并且由于损坏的html内容,我面临着非常奇怪的行为。我有一个phtml文件,其中包含一些php,然后是javascript,如下所示:

<div class="some-class">
 <!--html -->
 </div>
 <script>
 //...
$element.wrap('<div class="red"></div>');
//..
</script>

在父模板(也是phtml文件)中,使用php include包含了该文件(是的,这是Magento核心模块不使用块就包含它的方式,如下:)>]

<?php include 'path/to/file.phtml'; ?>

问题是,在页面源上,我得到了以下意外的html:

<div class="some-class">
<!--html -->
</div>
<script>
//...
$element.wrap('<div class="red"></script></div>');
//..broken content here due to the moved script tag

注意已移动的结束标记..

我知道这种情况可能会由于多个问题而发生,但是我怀疑Incapsula是因为发生问题的唯一环境使用了Incapsula。>

请提出与缓存有关的可能方案,任何帮助或想法都应受到赞赏。

谢谢

我正在将Magento2与fpc,清漆,redis和Incapsula一起使用,并且由于损坏的html内容,我面临着非常奇怪的行为。我有一个phtml文件,其中包含一些php,后跟javascript为...

caching redis magento2 varnish incapsula
1个回答
0
投票

尝试使用这种方式在phtml中回显其他phtml。

<?php
echo $block->getLayout()
    ->createBlock("Magento\Framework\View\Element\Template")
    ->setTemplate("Your_Module::file.phtml")
    ->toHtml();
?>
© www.soinside.com 2019 - 2024. All rights reserved.