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 24, 2021
1 parent abcf5b9 commit 7dd0ca5
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
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function macroBlock(MacroNode $node, PhpWriter $writer): string
$node->modifiers .= '|escape';
$node->closingCode = $writer->write(
'<?php $ʟ_fi = new LR\FilterInfo(%var); echo %modifyContent(ob_get_clean()); ?>',
$node->context[0]
implode($node->context)
);
return 'ob_start(function () {});';
}
Expand Down
5 changes: 4 additions & 1 deletion tests/Latte/contentType.compatibility.phpt
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,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 7dd0ca5

Please sign in to comment.