Skip to content

Commit

Permalink
latte: yield sub-nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz committed Sep 12, 2023
1 parent ef53832 commit c5b4c65
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Bridge/Nette/Latte/Extension/Node/ImgNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Contributte\Imagist\Bridge\Nette\Latte\Extension\Node;

use Generator;
use Latte\Compiler\Nodes\Html\ElementNode;
use Latte\Compiler\Nodes\Php\Expression\ArrayNode;
use Latte\Compiler\Nodes\Php\ExpressionNode;
Expand All @@ -12,11 +13,11 @@
final class ImgNode extends StatementNode
{

private ?ElementNode $element;
public ?ElementNode $element;

private ExpressionNode $image;
public ExpressionNode $image;

private ArrayNode $arguments;
public ArrayNode $arguments;

public static function create(Tag $tag): self
{
Expand Down Expand Up @@ -51,4 +52,17 @@ public function print(PrintContext $context): string
return $code;
}

/**
* @return Generator<ElementNode|ExpressionNode>
*/
public function &getIterator(): Generator
{
if ($this->element) {
yield $this->element;
}

yield $this->image;
yield $this->arguments;
}

}

0 comments on commit c5b4c65

Please sign in to comment.