Skip to content

Commit

Permalink
{block|filter} passes full content-type to FilterInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 18, 2021
1 parent 77a0d5f commit 20d77a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Latte/Macros/BlockMacros.php
Expand Up @@ -400,7 +400,7 @@ public function macroBlockEnd(MacroNode $node, PhpWriter $writer)

} elseif ($node->modifiers) { // anonymous block with modifier
$node->modifiers .= '|escape';
return $writer->write('$_fi = new LR\FilterInfo(%var); echo %modifyContent(ob_get_clean());', $node->context[0]);
return $writer->write('$_fi = new LR\FilterInfo(%var); echo %modifyContent(ob_get_clean());', implode($node->context));
}
}

Expand Down
5 changes: 4 additions & 1 deletion tests/Latte/contentType.compatibility.phpt
Expand Up @@ -379,4 +379,7 @@ Assert::same('<p> " &lt;</p>', $latte->renderToString('context1c'));
Assert::same('<p title="<hr> &quot;"</p>', $latte->renderToString('context2'));
Assert::same('<p title=" &quot;"></p>', $latte->renderToString('context2a'));
Assert::same('<!--<hr> &lt;-->', $latte->renderToString('context6'));
Assert::same('<!-- <-->', $latte->renderToString('context6a'));

Assert::error(function () use ($latte) {
$latte->renderToString('context6a');
}, E_USER_WARNING, 'Filter |stripHtml used with incompatible type HTMLCOMMENT');
6 changes: 6 additions & 0 deletions tests/Latte/contentType.html.javascript.phpt
Expand Up @@ -110,3 +110,9 @@ Assert::match(
<div n:foreach="[a, b] as $i">{$i}</div>
')
);

// trim inside <script>
Assert::match(
'<script>123;</script>',
$latte->renderToString('<script>{block|trim} 123; {/block}</script>')
);

0 comments on commit 20d77a0

Please sign in to comment.