Skip to content

Commit

Permalink
{block|filter} passes full content-type to FilterInfo (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 22, 2021
1 parent 6261d6a commit db1f437
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 @@ -261,7 +261,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 $writer->write('ob_start(function () {}) %node.line;');
}
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::exception(function () use ($latte) {
$latte->renderToString('context6a');
}, Latte\RuntimeException::class, '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 db1f437

Please sign in to comment.