-
-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy pathFormContainerNode.php
More file actions
60 lines (47 loc) · 1.29 KB
/
FormContainerNode.php
File metadata and controls
60 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* This file is part of the Latte (https://latte.nette.org)
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
*/
declare(strict_types=1);
namespace Nette\Bridges\FormsLatte\Nodes;
use Latte\Compiler\Nodes\AreaNode;
use Latte\Compiler\Nodes\Php\ExpressionNode;
use Latte\Compiler\Nodes\StatementNode;
use Latte\Compiler\PrintContext;
use Latte\Compiler\Tag;
/**
* {formContainer ...}
*/
class FormContainerNode extends StatementNode
{
public ExpressionNode $name;
public AreaNode $content;
/** @return \Generator<int, ?array, array{AreaNode, ?Tag}, static|AreaNode> */
public static function create(Tag $tag): \Generator
{
$tag->outputMode = $tag::OutputRemoveIndentation;
$tag->expectArguments();
$node = new static;
$node->name = $tag->parser->parseUnquotedStringOrExpression();
[$node->content] = yield;
return $node;
}
public function print(PrintContext $context): string
{
return $context->format(
'$this->global->forms->begin($formContainer = $this->global->forms->item(%node)) %line; '
. '%node '
. '$this->global->forms->end(); $formContainer = $this->global->forms->current();'
. "\n\n",
$this->name,
$this->position,
$this->content,
);
}
public function &getIterator(): \Generator
{
yield $this->name;
yield $this->content;
}
}