Skip to content

Commit

Permalink
Add a way to stream template rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Dec 16, 2024
1 parent 918f52e commit a53048b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 3.17.2 (2024-XX-XX)

* n/a
* Add a way to stream template rendering (via `$twig->load('index')->stream([])`)

# 3.17.1 (2024-12-12)

Expand Down
5 changes: 5 additions & 0 deletions src/TemplateWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public function display(array $context = [])
$this->template->display($context, \func_get_args()[1] ?? []);
}

public function stream(array $context = []): iterable
{
yield from $this->template->yield($context);
}

public function hasBlock(string $name, array $context = []): bool
{
return $this->template->hasBlock($name, $context);
Expand Down

0 comments on commit a53048b

Please sign in to comment.