mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 20:47:28 +00:00
Fix CoreExtension::captureOutput
This commit is contained in:
@@ -1888,30 +1888,22 @@ final class CoreExtension extends AbstractExtension
|
||||
*/
|
||||
public static function captureOutput(iterable $body): string
|
||||
{
|
||||
$output = '';
|
||||
$level = ob_get_level();
|
||||
ob_start();
|
||||
|
||||
try {
|
||||
foreach ($body as $data) {
|
||||
if (ob_get_length()) {
|
||||
$output .= ob_get_clean();
|
||||
ob_start();
|
||||
}
|
||||
|
||||
$output .= $data;
|
||||
echo $data;
|
||||
}
|
||||
|
||||
if (ob_get_length()) {
|
||||
$output .= ob_get_clean();
|
||||
}
|
||||
} finally {
|
||||
} catch (\Throwable $e) {
|
||||
while (ob_get_level() > $level) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $output;
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user