@vituum/vite-plugin-latte 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/handler.js +9 -0
- package/index.js +138 -0
- package/index.php +173 -0
- package/latte/AssetFilter.php +11 -0
- package/latte/FetchFunction.php +28 -0
- package/latte/IconFilter.php +14 -0
- package/latte/JsonTag.php +64 -0
- package/latte/PlaceholderFunction.php +11 -0
- package/latte/RandomColorFunction.php +14 -0
- package/latte/TelFilter.php +22 -0
- package/package.json +35 -0
- package/vendor/autoload.php +7 -0
- package/vendor/bin/latte-lint +107 -0
- package/vendor/composer/ClassLoader.php +572 -0
- package/vendor/composer/InstalledVersions.php +350 -0
- package/vendor/composer/LICENSE +21 -0
- package/vendor/composer/autoload_classmap.php +183 -0
- package/vendor/composer/autoload_namespaces.php +9 -0
- package/vendor/composer/autoload_psr4.php +9 -0
- package/vendor/composer/autoload_real.php +57 -0
- package/vendor/composer/autoload_static.php +193 -0
- package/vendor/composer/installed.json +93 -0
- package/vendor/composer/installed.php +32 -0
- package/vendor/composer/platform_check.php +26 -0
- package/vendor/latte/latte/bin/latte-lint +29 -0
- package/vendor/latte/latte/composer.json +53 -0
- package/vendor/latte/latte/license.md +60 -0
- package/vendor/latte/latte/ncs.php +14 -0
- package/vendor/latte/latte/ncs.xml +9 -0
- package/vendor/latte/latte/readme.md +21 -0
- package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +114 -0
- package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +99 -0
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.panel.phtml +98 -0
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.tab.phtml +15 -0
- package/vendor/latte/latte/src/Latte/Compiler/Block.php +44 -0
- package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +244 -0
- package/vendor/latte/latte/src/Latte/Compiler/ExpressionBuilder.php +128 -0
- package/vendor/latte/latte/src/Latte/Compiler/Node.php +28 -0
- package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +132 -0
- package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +77 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AreaNode.php +17 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +27 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +59 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +48 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/BogusTagNode.php +46 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/CommentNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +129 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/QuotedValue.php +53 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/NopNode.php +21 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ComplexTypeNode.php +17 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayAccessNode.php +41 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayItemNode.php +52 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +94 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/BinaryOpNode.php +65 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CastNode.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CloneNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +73 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureUseNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/EmptyNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ErrorSuppressNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FilterCallNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallableNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InRangeNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InstanceofNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MatchNode.php +49 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallNode.php +50 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallableNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NewNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NotNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PropertyFetchNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticCallNode.php +55 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticCallableNode.php +47 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticPropertyFetchNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TernaryNode.php +50 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/VariableNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +17 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/FilterNode.php +67 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IdentifierNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IntersectionTypeNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/MatchArmNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +107 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NameNode.php +89 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NullableTypeNode.php +35 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ParameterNode.php +54 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/BooleanNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/EncapsedStringNode.php +80 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/EncapsedStringPartNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/FloatNode.php +63 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/IntegerNode.php +70 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/NullNode.php +29 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/StringNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ScalarNode.php +15 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/SuperiorTypeNode.php +29 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/UnionTypeNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VarLikeIdentifierNode.php +21 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/StatementNode.php +15 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TemplateNode.php +34 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TextNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +227 -0
- package/vendor/latte/latte/src/Latte/Compiler/Position.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +334 -0
- package/vendor/latte/latte/src/Latte/Compiler/Tag.php +117 -0
- package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +399 -0
- package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +388 -0
- package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +580 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +206 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +391 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +448 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +506 -0
- package/vendor/latte/latte/src/Latte/Compiler/Token.php +259 -0
- package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +151 -0
- package/vendor/latte/latte/src/Latte/ContentType.php +22 -0
- package/vendor/latte/latte/src/Latte/Engine.php +591 -0
- package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +160 -0
- package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +232 -0
- package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +232 -0
- package/vendor/latte/latte/src/Latte/Essential/Filters.php +591 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +161 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +98 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +74 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DebugbreakNode.php +53 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +134 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DoNode.php +49 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DumpNode.php +58 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +125 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +60 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +81 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +91 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +155 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +141 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +82 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +180 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ImportNode.php +49 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +140 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeFileNode.php +81 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +94 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NAttrNode.php +105 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NClassNode.php +54 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +79 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ParametersNode.php +84 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/PrintNode.php +70 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RawPhpNode.php +46 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SkipNode.php +71 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +62 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +118 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplatePrintNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplateTypeNode.php +38 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TraceNode.php +35 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +104 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +75 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarNode.php +106 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarPrintNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarTypeNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +81 -0
- package/vendor/latte/latte/src/Latte/Essential/Passes.php +115 -0
- package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +28 -0
- package/vendor/latte/latte/src/Latte/Essential/RollbackException.php +16 -0
- package/vendor/latte/latte/src/Latte/Essential/Tracer.php +117 -0
- package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +101 -0
- package/vendor/latte/latte/src/Latte/Extension.php +97 -0
- package/vendor/latte/latte/src/Latte/Helpers.php +96 -0
- package/vendor/latte/latte/src/Latte/Loader.php +37 -0
- package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +95 -0
- package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +76 -0
- package/vendor/latte/latte/src/Latte/Policy.php +24 -0
- package/vendor/latte/latte/src/Latte/PositionAwareException.php +50 -0
- package/vendor/latte/latte/src/Latte/Runtime/Block.php +24 -0
- package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +151 -0
- package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +39 -0
- package/vendor/latte/latte/src/Latte/Runtime/Filters.php +234 -0
- package/vendor/latte/latte/src/Latte/Runtime/Html.php +35 -0
- package/vendor/latte/latte/src/Latte/Runtime/HtmlStringable.php +17 -0
- package/vendor/latte/latte/src/Latte/Runtime/Template.php +381 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallableNode.php +29 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +32 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallableNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/PropertyFetchNode.php +32 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +73 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticCallNode.php +31 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticCallableNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticPropertyFetchNode.php +32 -0
- package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +116 -0
- package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +132 -0
- package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +185 -0
- package/vendor/latte/latte/src/Latte/Strict.php +101 -0
- package/vendor/latte/latte/src/Latte/attributes.php +24 -0
- package/vendor/latte/latte/src/Latte/exceptions.php +69 -0
- package/vendor/latte/latte/src/Tools/Linter.php +175 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\CompileException;
|
|
13
|
+
use Latte\Compiler\Nodes\FragmentNode;
|
|
14
|
+
use Latte\Compiler\Nodes\Php\Expression\ArrayNode;
|
|
15
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
16
|
+
use Latte\Compiler\Nodes\Php\Scalar\StringNode;
|
|
17
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
18
|
+
use Latte\Compiler\Nodes\TextNode;
|
|
19
|
+
use Latte\Compiler\PrintContext;
|
|
20
|
+
use Latte\Compiler\Tag;
|
|
21
|
+
use Latte\Compiler\TemplateParser;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* {embed [block|file] name [,] [params]}
|
|
26
|
+
*/
|
|
27
|
+
class EmbedNode extends StatementNode
|
|
28
|
+
{
|
|
29
|
+
public ExpressionNode $name;
|
|
30
|
+
public string $mode;
|
|
31
|
+
public ArrayNode $args;
|
|
32
|
+
public FragmentNode $blocks;
|
|
33
|
+
public int|string|null $layer;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/** @return \Generator<int, ?array, array{FragmentNode, ?Tag}, static> */
|
|
37
|
+
public static function create(Tag $tag, TemplateParser $parser): \Generator
|
|
38
|
+
{
|
|
39
|
+
if ($tag->isNAttribute()) {
|
|
40
|
+
throw new CompileException('Attribute n:embed is not supported.', $tag->position);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
$tag->outputMode = $tag::OutputRemoveIndentation;
|
|
44
|
+
$tag->expectArguments();
|
|
45
|
+
|
|
46
|
+
$node = new static;
|
|
47
|
+
$mode = $tag->parser->tryConsumeModifier('block', 'file')?->text;
|
|
48
|
+
$node->name = $tag->parser->parseUnquotedStringOrExpression();
|
|
49
|
+
$node->mode = $mode ?? ($node->name instanceof StringNode && preg_match('~[\w-]+$~DA', $node->name->value) ? 'block' : 'file');
|
|
50
|
+
$tag->parser->stream->tryConsume(',');
|
|
51
|
+
$node->args = $tag->parser->parseArguments();
|
|
52
|
+
|
|
53
|
+
$prevIndex = $parser->blockLayer;
|
|
54
|
+
$parser->blockLayer = $node->layer = count($parser->blocks);
|
|
55
|
+
$parser->blocks[$parser->blockLayer] = [];
|
|
56
|
+
[$node->blocks] = yield;
|
|
57
|
+
|
|
58
|
+
foreach ($node->blocks->children as $child) {
|
|
59
|
+
if (!$child instanceof ImportNode && !$child instanceof BlockNode && !$child instanceof TextNode) {
|
|
60
|
+
throw new CompileException('Unexpected content inside {embed} tags.', $child->position);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
$parser->blockLayer = $prevIndex;
|
|
65
|
+
return $node;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
public function print(PrintContext $context): string
|
|
70
|
+
{
|
|
71
|
+
$imports = '';
|
|
72
|
+
foreach ($this->blocks->children as $child) {
|
|
73
|
+
if ($child instanceof ImportNode) {
|
|
74
|
+
$imports .= $child->print($context);
|
|
75
|
+
} else {
|
|
76
|
+
$child->print($context);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return $this->mode === 'file'
|
|
81
|
+
? $context->format(
|
|
82
|
+
<<<'XX'
|
|
83
|
+
$this->enterBlockLayer(%dump, get_defined_vars()) %line; %raw
|
|
84
|
+
try {
|
|
85
|
+
$this->createTemplate(%node, %node, "embed")->renderToContentType(%dump) %1.line;
|
|
86
|
+
} finally {
|
|
87
|
+
$this->leaveBlockLayer();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
XX,
|
|
91
|
+
$this->layer,
|
|
92
|
+
$this->position,
|
|
93
|
+
$imports,
|
|
94
|
+
$this->name,
|
|
95
|
+
$this->args,
|
|
96
|
+
$context->getEscaper()->export(),
|
|
97
|
+
)
|
|
98
|
+
: $context->format(
|
|
99
|
+
<<<'XX'
|
|
100
|
+
$this->enterBlockLayer(%dump, get_defined_vars()) %line; %raw
|
|
101
|
+
$this->copyBlockLayer();
|
|
102
|
+
try {
|
|
103
|
+
$this->renderBlock(%node, %node, %dump) %1.line;
|
|
104
|
+
} finally {
|
|
105
|
+
$this->leaveBlockLayer();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
XX,
|
|
109
|
+
$this->layer,
|
|
110
|
+
$this->position,
|
|
111
|
+
$imports,
|
|
112
|
+
$this->name,
|
|
113
|
+
$this->args,
|
|
114
|
+
$context->getEscaper()->export(),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
public function &getIterator(): \Generator
|
|
120
|
+
{
|
|
121
|
+
yield $this->name;
|
|
122
|
+
yield $this->args;
|
|
123
|
+
yield $this->blocks;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\CompileException;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Nodes\Php\Scalar\BooleanNode;
|
|
15
|
+
use Latte\Compiler\Nodes\Php\Scalar\NullNode;
|
|
16
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
17
|
+
use Latte\Compiler\PrintContext;
|
|
18
|
+
use Latte\Compiler\Tag;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* {extends none | auto | "file"}
|
|
23
|
+
* {layout none | auto | "file"}
|
|
24
|
+
*/
|
|
25
|
+
class ExtendsNode extends StatementNode
|
|
26
|
+
{
|
|
27
|
+
public ExpressionNode $extends;
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
public static function create(Tag $tag): static
|
|
31
|
+
{
|
|
32
|
+
$tag->expectArguments();
|
|
33
|
+
$node = new static;
|
|
34
|
+
if (!$tag->isInHead()) {
|
|
35
|
+
throw new CompileException("{{$tag->name}} must be placed in template head.", $tag->position);
|
|
36
|
+
} elseif (isset($tag->data->extends)) {
|
|
37
|
+
throw new CompileException("Multiple {{$tag->name}} declarations are not allowed.", $tag->position);
|
|
38
|
+
} elseif ($tag->parser->stream->tryConsume('auto')) {
|
|
39
|
+
$node->extends = new NullNode;
|
|
40
|
+
} elseif ($tag->parser->stream->tryConsume('none')) {
|
|
41
|
+
$node->extends = new BooleanNode(false);
|
|
42
|
+
} else {
|
|
43
|
+
$node->extends = $tag->parser->parseUnquotedStringOrExpression();
|
|
44
|
+
}
|
|
45
|
+
$tag->data->extends = true;
|
|
46
|
+
return $node;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
public function print(PrintContext $context): string
|
|
51
|
+
{
|
|
52
|
+
return $context->format('$this->parentName = %node;', $this->extends);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
public function &getIterator(): \Generator
|
|
57
|
+
{
|
|
58
|
+
yield $this->extends;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\AreaNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
15
|
+
use Latte\Compiler\Position;
|
|
16
|
+
use Latte\Compiler\PrintContext;
|
|
17
|
+
use Latte\Compiler\Tag;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* {first [$width]}
|
|
22
|
+
* {last [$width]}
|
|
23
|
+
* {sep [$width]}
|
|
24
|
+
*/
|
|
25
|
+
class FirstLastSepNode extends StatementNode
|
|
26
|
+
{
|
|
27
|
+
public string $name;
|
|
28
|
+
public ?ExpressionNode $width;
|
|
29
|
+
public AreaNode $then;
|
|
30
|
+
public ?AreaNode $else = null;
|
|
31
|
+
public ?Position $elseLine = null;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/** @return \Generator<int, ?array, array{AreaNode, ?Tag}, static> */
|
|
35
|
+
public static function create(Tag $tag): \Generator
|
|
36
|
+
{
|
|
37
|
+
$node = new static;
|
|
38
|
+
$node->name = $tag->name;
|
|
39
|
+
$node->width = $tag->parser->isEnd() ? null : $tag->parser->parseExpression();
|
|
40
|
+
|
|
41
|
+
[$node->then, $nextTag] = yield ['else'];
|
|
42
|
+
if ($nextTag?->name === 'else') {
|
|
43
|
+
$node->elseLine = $nextTag->position;
|
|
44
|
+
[$node->else] = yield;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return $node;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
public function print(PrintContext $context): string
|
|
52
|
+
{
|
|
53
|
+
$cond = match ($this->name) {
|
|
54
|
+
'first' => '$iterator->isFirst',
|
|
55
|
+
'last' => '$iterator->isLast',
|
|
56
|
+
'sep' => '!$iterator->isLast',
|
|
57
|
+
};
|
|
58
|
+
return $context->format(
|
|
59
|
+
$this->else
|
|
60
|
+
? "if ($cond(%node)) %line { %node } else %line { %node }\n"
|
|
61
|
+
: "if ($cond(%node)) %line { %node }\n",
|
|
62
|
+
$this->width,
|
|
63
|
+
$this->position,
|
|
64
|
+
$this->then,
|
|
65
|
+
$this->elseLine,
|
|
66
|
+
$this->else,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
public function &getIterator(): \Generator
|
|
72
|
+
{
|
|
73
|
+
if ($this->width) {
|
|
74
|
+
yield $this->width;
|
|
75
|
+
}
|
|
76
|
+
yield $this->then;
|
|
77
|
+
if ($this->else) {
|
|
78
|
+
yield $this->else;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\AreaNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
use Latte\Compiler\Tag;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* {for $init; $cond; $next}
|
|
21
|
+
*/
|
|
22
|
+
class ForNode extends StatementNode
|
|
23
|
+
{
|
|
24
|
+
/** @var ExpressionNode[] */
|
|
25
|
+
public array $init = [];
|
|
26
|
+
public ?ExpressionNode $condition;
|
|
27
|
+
|
|
28
|
+
/** @var ExpressionNode[] */
|
|
29
|
+
public array $next = [];
|
|
30
|
+
public AreaNode $content;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/** @return \Generator<int, ?array, array{AreaNode, ?Tag}, static> */
|
|
34
|
+
public static function create(Tag $tag): \Generator
|
|
35
|
+
{
|
|
36
|
+
$tag->expectArguments();
|
|
37
|
+
$stream = $tag->parser->stream;
|
|
38
|
+
$node = new static;
|
|
39
|
+
while (!$stream->is(';')) {
|
|
40
|
+
$node->init[] = $tag->parser->parseExpression();
|
|
41
|
+
$stream->tryConsume(',');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
$stream->consume(';');
|
|
45
|
+
$node->condition = $stream->is(';') ? null : $tag->parser->parseExpression();
|
|
46
|
+
$stream->consume(';');
|
|
47
|
+
while (!$tag->parser->isEnd()) {
|
|
48
|
+
$node->next[] = $tag->parser->parseExpression();
|
|
49
|
+
$stream->tryConsume(',');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[$node->content] = yield;
|
|
53
|
+
return $node;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
public function print(PrintContext $context): string
|
|
58
|
+
{
|
|
59
|
+
return $context->format(
|
|
60
|
+
<<<'XX'
|
|
61
|
+
for (%args; %node; %args) %line {
|
|
62
|
+
%node
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
XX,
|
|
66
|
+
$this->init,
|
|
67
|
+
$this->condition,
|
|
68
|
+
$this->next,
|
|
69
|
+
$this->position,
|
|
70
|
+
$this->content,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
public function &getIterator(): \Generator
|
|
76
|
+
{
|
|
77
|
+
foreach ($this->init as &$item) {
|
|
78
|
+
yield $item;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if ($this->condition) {
|
|
82
|
+
yield $this->condition;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
foreach ($this->next as &$item) {
|
|
86
|
+
yield $item;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
yield $this->content;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\CompileException;
|
|
13
|
+
use Latte\Compiler\Nodes\AreaNode;
|
|
14
|
+
use Latte\Compiler\Nodes\NopNode;
|
|
15
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
16
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
17
|
+
use Latte\Compiler\Position;
|
|
18
|
+
use Latte\Compiler\PrintContext;
|
|
19
|
+
use Latte\Compiler\Tag;
|
|
20
|
+
use Latte\Compiler\TagParser;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* {foreach $expr as $key => $value} & {else}
|
|
25
|
+
*/
|
|
26
|
+
class ForeachNode extends StatementNode
|
|
27
|
+
{
|
|
28
|
+
public ExpressionNode $expression;
|
|
29
|
+
public ?ExpressionNode $key = null;
|
|
30
|
+
public bool $byRef = false;
|
|
31
|
+
public ExpressionNode $value;
|
|
32
|
+
public AreaNode $content;
|
|
33
|
+
public ?AreaNode $else = null;
|
|
34
|
+
public ?Position $elseLine = null;
|
|
35
|
+
public ?bool $iterator = null;
|
|
36
|
+
public bool $checkArgs = true;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/** @return \Generator<int, ?array, array{AreaNode, ?Tag}, static|NopNode> */
|
|
40
|
+
public static function create(Tag $tag): \Generator
|
|
41
|
+
{
|
|
42
|
+
$tag->expectArguments();
|
|
43
|
+
$node = new static;
|
|
44
|
+
self::parseArguments($tag->parser, $node);
|
|
45
|
+
$tag->data->iterateWhile = [$node->key, $node->value];
|
|
46
|
+
|
|
47
|
+
$modifier = $tag->parser->parseModifier();
|
|
48
|
+
foreach ($modifier->filters as $filter) {
|
|
49
|
+
match ($filter->name->name) {
|
|
50
|
+
'nocheck', 'noCheck' => $node->checkArgs = false,
|
|
51
|
+
'noiterator', 'noIterator' => $node->iterator = false,
|
|
52
|
+
default => throw new CompileException('Only modifiers |noiterator and |nocheck are allowed here.', $tag->position),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if ($tag->void) {
|
|
57
|
+
$node->content = new NopNode;
|
|
58
|
+
return $node;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[$node->content, $nextTag] = yield ['else'];
|
|
62
|
+
if ($nextTag?->name === 'else') {
|
|
63
|
+
$node->elseLine = $nextTag->position;
|
|
64
|
+
[$node->else] = yield;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return $node;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
private static function parseArguments(TagParser $parser, self $node): void
|
|
72
|
+
{
|
|
73
|
+
$stream = $parser->stream;
|
|
74
|
+
$node->expression = $parser->parseExpression();
|
|
75
|
+
$stream->consume('as');
|
|
76
|
+
if (!$stream->is('&')) {
|
|
77
|
+
$node->value = $parser->parseExpression();
|
|
78
|
+
if (!$stream->tryConsume('=>')) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
$node->key = $node->value;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
$node->byRef = (bool) $stream->tryConsume('&');
|
|
85
|
+
$node->value = $parser->parseExpression();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
public function print(PrintContext $context): string
|
|
90
|
+
{
|
|
91
|
+
$content = $this->content->print($context);
|
|
92
|
+
$iterator = $this->else || ($this->iterator ?? preg_match('#\$iterator\W|\Wget_defined_vars\W#', $content));
|
|
93
|
+
|
|
94
|
+
if ($this->else) {
|
|
95
|
+
$content .= $context->format(
|
|
96
|
+
'} if ($iterator->isEmpty()) %line { ',
|
|
97
|
+
$this->elseLine,
|
|
98
|
+
) . $this->else->print($context);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if ($iterator) {
|
|
102
|
+
return $context->format(
|
|
103
|
+
<<<'XX'
|
|
104
|
+
foreach ($iterator = $ʟ_it = new Latte\Essential\CachingIterator(%node, $ʟ_it ?? null) as %raw) %line {
|
|
105
|
+
%raw
|
|
106
|
+
}
|
|
107
|
+
$iterator = $ʟ_it = $ʟ_it->getParent();
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
XX,
|
|
111
|
+
$this->expression,
|
|
112
|
+
$this->printArgs($context),
|
|
113
|
+
$this->position,
|
|
114
|
+
$content,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
} else {
|
|
118
|
+
return $context->format(
|
|
119
|
+
<<<'XX'
|
|
120
|
+
foreach (%node as %raw) %line {
|
|
121
|
+
%raw
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
XX,
|
|
126
|
+
$this->expression,
|
|
127
|
+
$this->printArgs($context),
|
|
128
|
+
$this->position,
|
|
129
|
+
$content,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
private function printArgs(PrintContext $context): string
|
|
136
|
+
{
|
|
137
|
+
return ($this->key ? $this->key->print($context) . ' => ' : '')
|
|
138
|
+
. ($this->byRef ? '&' : '')
|
|
139
|
+
. $this->value->print($context);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
public function &getIterator(): \Generator
|
|
144
|
+
{
|
|
145
|
+
yield $this->expression;
|
|
146
|
+
if ($this->key) {
|
|
147
|
+
yield $this->key;
|
|
148
|
+
}
|
|
149
|
+
yield $this->value;
|
|
150
|
+
yield $this->content;
|
|
151
|
+
if ($this->else) {
|
|
152
|
+
yield $this->else;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\AreaNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\Expression\ArrayNode;
|
|
14
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
15
|
+
use Latte\Compiler\Position;
|
|
16
|
+
use Latte\Compiler\PrintContext;
|
|
17
|
+
use Latte\Compiler\Tag;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* {ifchanged [$var]} ... {else}
|
|
22
|
+
*/
|
|
23
|
+
class IfChangedNode extends StatementNode
|
|
24
|
+
{
|
|
25
|
+
public ArrayNode $conditions;
|
|
26
|
+
public AreaNode $then;
|
|
27
|
+
public ?AreaNode $else = null;
|
|
28
|
+
public ?Position $elseLine = null;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/** @return \Generator<int, ?array, array{AreaNode, ?Tag}, static> */
|
|
32
|
+
public static function create(Tag $tag): \Generator
|
|
33
|
+
{
|
|
34
|
+
$node = new static;
|
|
35
|
+
$node->conditions = $tag->parser->parseArguments();
|
|
36
|
+
|
|
37
|
+
[$node->then, $nextTag] = yield ['else'];
|
|
38
|
+
if ($nextTag?->name === 'else') {
|
|
39
|
+
$node->elseLine = $nextTag->position;
|
|
40
|
+
[$node->else] = yield;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return $node;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
public function print(PrintContext $context): string
|
|
48
|
+
{
|
|
49
|
+
return $this->conditions->items
|
|
50
|
+
? $this->printExpression($context)
|
|
51
|
+
: $this->printCapturing($context);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
private function printExpression(PrintContext $context): string
|
|
56
|
+
{
|
|
57
|
+
return $this->else
|
|
58
|
+
? $context->format(
|
|
59
|
+
<<<'XX'
|
|
60
|
+
if (($ʟ_loc[%dump] ?? null) !== ($ʟ_tmp = %node)) {
|
|
61
|
+
$ʟ_loc[%0.dump] = $ʟ_tmp;
|
|
62
|
+
%node
|
|
63
|
+
} else %line {
|
|
64
|
+
%node
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
XX,
|
|
69
|
+
$context->generateId(),
|
|
70
|
+
$this->conditions,
|
|
71
|
+
$this->then,
|
|
72
|
+
$this->elseLine,
|
|
73
|
+
$this->else,
|
|
74
|
+
)
|
|
75
|
+
: $context->format(
|
|
76
|
+
<<<'XX'
|
|
77
|
+
if (($ʟ_loc[%dump] ?? null) !== ($ʟ_tmp = %node)) {
|
|
78
|
+
$ʟ_loc[%0.dump] = $ʟ_tmp;
|
|
79
|
+
%2.node
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
XX,
|
|
84
|
+
$context->generateId(),
|
|
85
|
+
$this->conditions,
|
|
86
|
+
$this->then,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
private function printCapturing(PrintContext $context): string
|
|
92
|
+
{
|
|
93
|
+
return $this->else
|
|
94
|
+
? $context->format(
|
|
95
|
+
<<<'XX'
|
|
96
|
+
ob_start(fn() => '');
|
|
97
|
+
try %line {
|
|
98
|
+
%node
|
|
99
|
+
} finally { $ʟ_tmp = ob_get_clean(); }
|
|
100
|
+
if (($ʟ_loc[%dump] ?? null) !== $ʟ_tmp) {
|
|
101
|
+
echo $ʟ_loc[%2.dump] = $ʟ_tmp;
|
|
102
|
+
} else %line {
|
|
103
|
+
%node
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
XX,
|
|
108
|
+
$this->position,
|
|
109
|
+
$this->then,
|
|
110
|
+
$context->generateId(),
|
|
111
|
+
$this->elseLine,
|
|
112
|
+
$this->else,
|
|
113
|
+
)
|
|
114
|
+
: $context->format(
|
|
115
|
+
<<<'XX'
|
|
116
|
+
ob_start(fn() => '');
|
|
117
|
+
try %line {
|
|
118
|
+
%node
|
|
119
|
+
} finally { $ʟ_tmp = ob_get_clean(); }
|
|
120
|
+
if (($ʟ_loc[%dump] ?? null) !== $ʟ_tmp) {
|
|
121
|
+
echo $ʟ_loc[%2.dump] = $ʟ_tmp;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
XX,
|
|
126
|
+
$this->position,
|
|
127
|
+
$this->then,
|
|
128
|
+
$context->generateId(),
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
public function &getIterator(): \Generator
|
|
134
|
+
{
|
|
135
|
+
yield $this->conditions;
|
|
136
|
+
yield $this->then;
|
|
137
|
+
if ($this->else) {
|
|
138
|
+
yield $this->else;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|