Skip to content

Commit

Permalink
Don't move Magento templates, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Krzeszowiak committed Mar 18, 2020
1 parent 31eeaa7 commit 4fa5447
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/code/Magento/Theme/Controller/Result/JsFooterPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(ScopeConfigInterface $scopeConfig)
*/
public function beforeSendResponse(Http $subject)
{
$content = $subject->getContent();
$content = $subject->getContent() ?? '';

$bodyClose = '</body';

Expand All @@ -57,6 +57,11 @@ public function beforeSendResponse(Http $subject)
$scriptClosePos = strpos($content, $scriptClose, $scriptOpenPos);
$script = substr($content, $scriptOpenPos, $scriptClosePos - $scriptOpenPos + strlen($scriptClose));

if (strpos($script, 'text/x-magento-template') !== false) {
$scriptOpenPos = strpos($content, $scriptOpen, $scriptClosePos);
continue;
}

$scripts .= "\n" . $script;
$content = str_replace($script, '', $content);
// Script cut out, continue search from its position.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public function sendResponseDataProvider(): array
"flag" => true,
"result" => "<body><h1>Test Title</h1>" .
"<script type=\"text/x-magento-template\">test</script>" .
"<p>Test Content</p>" .
"<script type=\"text/x-magento-init\">test</script>" .
"\n</body>"
"<p>Test Content</p>\n" .
"<script type=\"text/x-magento-init\">test</script>\n" .
"</body>"
],
'content_with_config_disable' => [
"content" => "<body><p>Test Content</p></body>",
Expand Down

0 comments on commit 4fa5447

Please sign in to comment.