Skip to content

Commit

Permalink
{capture} creates Html object only in HTML-TEXT context
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 24, 2021
1 parent 1369070 commit d50cdca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Latte/Macros/CoreMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function macroCapture(MacroNode $node, PhpWriter $writer): string
*/
public function macroCaptureEnd(MacroNode $node, PhpWriter $writer): string
{
$body = in_array($node->context[0], [Engine::CONTENT_HTML, Engine::CONTENT_XHTML], true)
$body = in_array(implode($node->context), [Engine::CONTENT_HTML, Engine::CONTENT_XHTML], true)
? 'ob_get_length() ? new LR\\Html(ob_get_clean()) : ob_get_clean()'
: 'ob_get_clean()';
return $writer->write(
Expand Down
5 changes: 5 additions & 0 deletions tests/Latte/CoreMacros.capture.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ Assert::match( // bug #215
'',
$latte->renderToString('{capture $var|strip} <html> {/capture}')
);

Assert::match(
'<!-- --> &lt;foo&gt;',
$latte->renderToString('<!-- {capture $x}<foo>{/capture} --> {$x}')
);

0 comments on commit d50cdca

Please sign in to comment.