@vituum/vite-plugin-latte 2.0.0-next.5 → 2.0.1
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 +1 -1
- package/index.js +2 -1
- package/package.json +20 -10
- package/vendor/composer/autoload_classmap.php +3 -2
- package/vendor/composer/autoload_static.php +3 -2
- package/vendor/composer/installed.json +21 -17
- package/vendor/composer/installed.php +8 -8
- package/vendor/latte/latte/composer.json +9 -2
- package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +7 -7
- package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +5 -4
- package/vendor/latte/latte/src/Bridges/Tracy/TracyExtension.php +2 -4
- package/vendor/latte/latte/src/Bridges/Tracy/dist/panel.phtml +2 -4
- package/vendor/latte/latte/src/Bridges/Tracy/dist/tab.phtml +2 -4
- package/vendor/latte/latte/src/Latte/Compiler/Block.php +1 -3
- package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +4 -8
- package/vendor/latte/latte/src/Latte/Compiler/Node.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +15 -6
- package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +14 -9
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AreaNode.php +7 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +6 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/BogusTagNode.php +4 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/CommentNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +5 -7
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ExpressionAttributeNode.php +6 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/TagNode.php +1 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/NopNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArrayItemNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ClosureUseNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ComplexTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayAccessNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AuxiliaryNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/BinaryOpNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CastNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CloneNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/EmptyNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FilterCallNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InstanceofNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MatchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NewNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticMethodCallNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticPropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TemporaryNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TernaryNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/VariableNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/FilterNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IdentifierNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/InterpolatedStringPartNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IntersectionTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListItemNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/MatchArmNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NameNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NullableTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/OperatorNode.php +1 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ParameterNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/BooleanNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/FloatNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/IntegerNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/InterpolatedStringNode.php +6 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/NullNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/StringNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ScalarNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/SuperiorTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/UnionTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VarLikeIdentifierNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VariadicPlaceholderNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/PrintNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/StatementNode.php +7 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TemplateNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TextNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +23 -15
- package/vendor/latte/latte/src/Latte/Compiler/Position.php +5 -7
- package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +30 -9
- package/vendor/latte/latte/src/Latte/Compiler/Tag.php +6 -6
- package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +4 -6
- package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +14 -11
- package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +2 -4
- package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +13 -11
- package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +21 -7
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +32 -19
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +28 -21
- package/vendor/latte/latte/src/Latte/Compiler/Token.php +10 -9
- package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +20 -14
- package/vendor/latte/latte/src/Latte/ContentType.php +4 -3
- package/vendor/latte/latte/src/Latte/Engine.php +64 -35
- package/vendor/latte/latte/src/Latte/Essential/AuxiliaryIterator.php +3 -7
- package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +1 -3
- package/vendor/latte/latte/src/Latte/Essential/Filters.php +65 -32
- package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +8 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +5 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CustomFunctionCallNode.php +2 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DebugbreakNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +6 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DoNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DumpNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +3 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +3 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +4 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +3 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +7 -8
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +6 -9
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ImportNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +8 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeFileNode.php +2 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +6 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/JumpNode.php +4 -8
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NAttrNode.php +3 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NClassNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NElseNode.php +8 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +4 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ParametersNode.php +4 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RawPhpNode.php +2 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +9 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplatePrintNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplateTypeNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TraceNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarNode.php +8 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarPrintNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarTypeNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +5 -5
- package/vendor/latte/latte/src/Latte/Essential/Passes.php +26 -15
- package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +1 -3
- package/vendor/latte/latte/src/Latte/Essential/RollbackException.php +1 -3
- package/vendor/latte/latte/src/Latte/Essential/Tracer.php +20 -13
- package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +9 -10
- package/vendor/latte/latte/src/Latte/Extension.php +10 -6
- package/vendor/latte/latte/src/Latte/Feature.php +24 -0
- package/vendor/latte/latte/src/Latte/Helpers.php +18 -10
- package/vendor/latte/latte/src/Latte/Loader.php +1 -3
- package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +8 -5
- package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +5 -13
- package/vendor/latte/latte/src/Latte/Policy.php +4 -3
- package/vendor/latte/latte/src/Latte/Runtime/Block.php +2 -4
- package/vendor/latte/latte/src/Latte/{Cache.php → Runtime/Cache.php} +12 -11
- package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +3 -5
- package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +10 -11
- package/vendor/latte/latte/src/Latte/Runtime/FunctionExecutor.php +4 -6
- package/vendor/latte/latte/src/Latte/Runtime/Helpers.php +5 -7
- package/vendor/latte/latte/src/Latte/Runtime/Html.php +3 -5
- package/vendor/latte/latte/src/Latte/Runtime/HtmlHelpers.php +18 -18
- package/vendor/latte/latte/src/Latte/Runtime/HtmlStringable.php +1 -3
- package/vendor/latte/latte/src/Latte/Runtime/Template.php +23 -42
- package/vendor/latte/latte/src/Latte/Runtime/XmlHelpers.php +5 -7
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +14 -8
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +17 -11
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/PropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticMethodCallNode.php +16 -10
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticPropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +6 -5
- package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +5 -4
- package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +17 -16
- package/vendor/latte/latte/src/Latte/attributes.php +7 -3
- package/vendor/latte/latte/src/Latte/exceptions.php +38 -3
- package/vendor/latte/latte/src/Tools/Linter.php +20 -14
- package/vendor/latte/latte/src/Tools/LinterExtension.php +26 -7
- package/vendor/nette/utils/composer.json +8 -1
- package/vendor/nette/utils/src/HtmlStringable.php +4 -1
- package/vendor/nette/utils/src/Iterators/CachingIterator.php +9 -24
- package/vendor/nette/utils/src/Iterators/Mapper.php +2 -3
- package/vendor/nette/utils/src/SmartObject.php +3 -0
- package/vendor/nette/utils/src/StaticClass.php +1 -1
- package/vendor/nette/utils/src/Translator.php +1 -1
- package/vendor/nette/utils/src/Utils/ArrayHash.php +1 -5
- package/vendor/nette/utils/src/Utils/ArrayList.php +3 -6
- package/vendor/nette/utils/src/Utils/Arrays.php +33 -10
- package/vendor/nette/utils/src/Utils/Callback.php +12 -7
- package/vendor/nette/utils/src/Utils/DateTime.php +1 -1
- package/vendor/nette/utils/src/Utils/FileInfo.php +5 -7
- package/vendor/nette/utils/src/Utils/FileSystem.php +5 -2
- package/vendor/nette/utils/src/Utils/Finder.php +27 -8
- package/vendor/nette/utils/src/Utils/Helpers.php +7 -1
- package/vendor/nette/utils/src/Utils/Html.php +123 -118
- package/vendor/nette/utils/src/Utils/Image.php +72 -54
- package/vendor/nette/utils/src/Utils/ImageColor.php +4 -0
- package/vendor/nette/utils/src/Utils/Iterables.php +16 -8
- package/vendor/nette/utils/src/Utils/Paginator.php +10 -43
- package/vendor/nette/utils/src/Utils/Reflection.php +17 -7
- package/vendor/nette/utils/src/Utils/ReflectionMethod.php +4 -1
- package/vendor/nette/utils/src/Utils/Strings.php +48 -15
- package/vendor/nette/utils/src/Utils/Type.php +41 -27
- package/vendor/nette/utils/src/Utils/Validators.php +8 -7
- package/vendor/latte/latte/src/Bridges/Tracy/panel.latte +0 -94
- package/vendor/latte/latte/src/Bridges/Tracy/tab.latte +0 -8
- package/vendor/latte/latte/src/Latte/PositionAwareException.php +0 -47
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\AreaNode;
|
|
@@ -18,9 +16,8 @@ use Latte\Compiler\Tag;
|
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* {first
|
|
22
|
-
* {
|
|
23
|
-
* {sep [$width]}
|
|
19
|
+
* {first} ... {/first}, {last} ... {/last}, {sep} ... {/sep}
|
|
20
|
+
* Loop iteration helpers inside {foreach}.
|
|
24
21
|
*/
|
|
25
22
|
class FirstLastSepNode extends StatementNode
|
|
26
23
|
{
|
|
@@ -31,7 +28,7 @@ class FirstLastSepNode extends StatementNode
|
|
|
31
28
|
public ?Position $elseLine = null;
|
|
32
29
|
|
|
33
30
|
|
|
34
|
-
/** @return \Generator<int, ?
|
|
31
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
35
32
|
public static function create(Tag $tag): \Generator
|
|
36
33
|
{
|
|
37
34
|
$node = $tag->node = new static;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\AreaNode;
|
|
@@ -18,7 +16,7 @@ use Latte\Helpers;
|
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* {for $
|
|
19
|
+
* {for $i = 0; $i < 10; $i++} ... {/for}
|
|
22
20
|
*/
|
|
23
21
|
class ForNode extends StatementNode
|
|
24
22
|
{
|
|
@@ -31,7 +29,7 @@ class ForNode extends StatementNode
|
|
|
31
29
|
public AreaNode $content;
|
|
32
30
|
|
|
33
31
|
|
|
34
|
-
/** @return \Generator<int, ?
|
|
32
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
35
33
|
public static function create(Tag $tag): \Generator
|
|
36
34
|
{
|
|
37
35
|
$tag->expectArguments();
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -24,11 +22,12 @@ use Latte\Compiler\Position;
|
|
|
24
22
|
use Latte\Compiler\PrintContext;
|
|
25
23
|
use Latte\Compiler\Tag;
|
|
26
24
|
use Latte\Compiler\TagParser;
|
|
27
|
-
use function array_map, array_unshift, implode, preg_match;
|
|
25
|
+
use function array_map, array_unshift, implode, is_string, preg_match;
|
|
28
26
|
|
|
29
27
|
|
|
30
28
|
/**
|
|
31
|
-
* {foreach $
|
|
29
|
+
* {foreach $array as $item} ... {/foreach}
|
|
30
|
+
* {foreach $array as $key => $value} ... {else} ... {/foreach}
|
|
32
31
|
*/
|
|
33
32
|
class ForeachNode extends StatementNode
|
|
34
33
|
{
|
|
@@ -43,7 +42,7 @@ class ForeachNode extends StatementNode
|
|
|
43
42
|
public bool $checkArgs = true;
|
|
44
43
|
|
|
45
44
|
|
|
46
|
-
/** @return \Generator<int, ?
|
|
45
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
47
46
|
public static function create(Tag $tag): \Generator
|
|
48
47
|
{
|
|
49
48
|
$tag->expectArguments();
|
|
@@ -160,8 +159,8 @@ class ForeachNode extends StatementNode
|
|
|
160
159
|
(new NodeTraverser)->traverse($node, function (Node $node) use (&$vars) {
|
|
161
160
|
if ($node instanceof self && $node->checkArgs) {
|
|
162
161
|
foreach ([$node->key, $node->value] as $var) {
|
|
163
|
-
if ($var instanceof VariableNode) {
|
|
164
|
-
$vars[$var->name][] = $node->position
|
|
162
|
+
if ($var instanceof VariableNode && is_string($var->name)) {
|
|
163
|
+
$vars[$var->name][] = $node->position?->line;
|
|
165
164
|
}
|
|
166
165
|
}
|
|
167
166
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\AreaNode;
|
|
@@ -18,7 +16,8 @@ use Latte\Compiler\Tag;
|
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* {ifchanged [$var]} ... {
|
|
19
|
+
* {ifchanged [$var]} ... {/ifchanged}
|
|
20
|
+
* Renders content only when value changes between iterations.
|
|
22
21
|
*/
|
|
23
22
|
class IfChangedNode extends StatementNode
|
|
24
23
|
{
|
|
@@ -28,7 +27,7 @@ class IfChangedNode extends StatementNode
|
|
|
28
27
|
public ?Position $elseLine = null;
|
|
29
28
|
|
|
30
29
|
|
|
31
|
-
/** @return \Generator<int, ?
|
|
30
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
32
31
|
public static function create(Tag $tag): \Generator
|
|
33
32
|
{
|
|
34
33
|
$node = $tag->node = new static;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -20,7 +18,8 @@ use Latte\Compiler\TemplateParser;
|
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
|
-
* n:ifcontent
|
|
21
|
+
* <div n:ifcontent> ... </div>
|
|
22
|
+
* Omits element if content is empty or whitespace only.
|
|
24
23
|
*/
|
|
25
24
|
class IfContentNode extends StatementNode
|
|
26
25
|
{
|
|
@@ -30,12 +29,13 @@ class IfContentNode extends StatementNode
|
|
|
30
29
|
public ?AreaNode $else = null;
|
|
31
30
|
|
|
32
31
|
|
|
33
|
-
/** @return \Generator<int, ?
|
|
32
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
34
33
|
public static function create(Tag $tag, TemplateParser $parser): \Generator
|
|
35
34
|
{
|
|
36
35
|
$node = $tag->node = new static;
|
|
37
36
|
$node->id = $parser->generateId();
|
|
38
37
|
[$node->content] = yield;
|
|
38
|
+
assert($tag->htmlElement !== null);
|
|
39
39
|
$node->htmlElement = $tag->htmlElement;
|
|
40
40
|
if (!$node->htmlElement->content) {
|
|
41
41
|
throw new CompileException("Unnecessary n:ifcontent on empty element <{$node->htmlElement->name}>", $tag->position);
|
|
@@ -46,8 +46,9 @@ class IfContentNode extends StatementNode
|
|
|
46
46
|
|
|
47
47
|
public function print(PrintContext $context): string
|
|
48
48
|
{
|
|
49
|
+
$saved = $this->htmlElement->content;
|
|
50
|
+
assert($saved !== null);
|
|
49
51
|
try {
|
|
50
|
-
$saved = $this->htmlElement->content;
|
|
51
52
|
$else = $this->else ?? new AuxiliaryNode(fn() => '');
|
|
52
53
|
$this->htmlElement->content = new AuxiliaryNode(fn() => <<<XX
|
|
53
54
|
ob_start();
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -24,10 +22,8 @@ use function in_array;
|
|
|
24
22
|
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
|
-
* {if $cond}
|
|
28
|
-
* {
|
|
29
|
-
* {ifset $var} & {elseifset $var}
|
|
30
|
-
* {ifset block} & {elseifset block}
|
|
25
|
+
* {if $cond} ... {elseif $cond} ... {else} ... {/if}
|
|
26
|
+
* {ifset $var} ... {elseifset $var} ... {/ifset}
|
|
31
27
|
*/
|
|
32
28
|
class IfNode extends StatementNode
|
|
33
29
|
{
|
|
@@ -39,11 +35,11 @@ class IfNode extends StatementNode
|
|
|
39
35
|
public bool $ifset = false;
|
|
40
36
|
|
|
41
37
|
|
|
42
|
-
/** @return \Generator<int, ?
|
|
38
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
43
39
|
public static function create(Tag $tag, TemplateParser $parser): \Generator
|
|
44
40
|
{
|
|
45
41
|
$node = $tag->node = new static;
|
|
46
|
-
$node->ifset = in_array($tag->name, ['ifset', 'elseifset'], true);
|
|
42
|
+
$node->ifset = in_array($tag->name, ['ifset', 'elseifset'], strict: true);
|
|
47
43
|
$node->capture = !$tag->isNAttribute() && $tag->name === 'if' && $tag->parser->isEnd();
|
|
48
44
|
$node->position = $tag->position;
|
|
49
45
|
if (!$node->capture) {
|
|
@@ -71,6 +67,7 @@ class IfNode extends StatementNode
|
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
if ($node->capture) {
|
|
70
|
+
assert($nextTag !== null);
|
|
74
71
|
$node->condition = $nextTag->parser->parseExpression();
|
|
75
72
|
}
|
|
76
73
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\Expression\ArrayNode;
|
|
@@ -17,7 +15,8 @@ use Latte\Compiler\Tag;
|
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
|
-
* {import
|
|
18
|
+
* {import 'file.latte'}
|
|
19
|
+
* Imports block definitions from another template.
|
|
21
20
|
*/
|
|
22
21
|
class ImportNode extends StatementNode
|
|
23
22
|
{
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -24,7 +22,7 @@ use Latte\Runtime\Template;
|
|
|
24
22
|
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
|
-
* {include
|
|
25
|
+
* {include #name|parent|this [from 'file.latte']}
|
|
28
26
|
*/
|
|
29
27
|
class IncludeBlockNode extends StatementNode
|
|
30
28
|
{
|
|
@@ -65,12 +63,14 @@ class IncludeBlockNode extends StatementNode
|
|
|
65
63
|
} elseif ($node->parent || $tokenName->is('this')) {
|
|
66
64
|
$item = $tag->closestTag(
|
|
67
65
|
[BlockNode::class, DefineNode::class],
|
|
68
|
-
fn($item) => $item->node
|
|
66
|
+
fn($item) => ($item->node instanceof BlockNode || $item->node instanceof DefineNode)
|
|
67
|
+
&& $item->node->block && !$item->node->block->isDynamic(),
|
|
69
68
|
);
|
|
70
|
-
if (!$item) {
|
|
69
|
+
if (!$item || !($item->node instanceof BlockNode || $item->node instanceof DefineNode)) {
|
|
71
70
|
throw new CompileException("Cannot include $tokenName->text block outside of any block.", $tag->position);
|
|
72
71
|
}
|
|
73
72
|
|
|
73
|
+
assert($item->node->block !== null);
|
|
74
74
|
$node->name = $item->node->block->name;
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -100,7 +100,7 @@ class IncludeBlockNode extends StatementNode
|
|
|
100
100
|
{
|
|
101
101
|
if ($this->name instanceof Scalar\StringNode || $this->name instanceof Scalar\IntegerNode) {
|
|
102
102
|
$staticName = (string) $this->name->value;
|
|
103
|
-
$block = $this->blocks[$this->layer][$staticName] ?? $this->blocks[Template::LayerLocal][$staticName] ?? null;
|
|
103
|
+
$block = ($this->layer !== null ? $this->blocks[$this->layer][$staticName] ?? null : null) ?? $this->blocks[Template::LayerLocal][$staticName] ?? null;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
return $context->format(
|
|
@@ -118,6 +118,7 @@ class IncludeBlockNode extends StatementNode
|
|
|
118
118
|
|
|
119
119
|
private function printBlockFrom(PrintContext $context, string $contentFilter): string
|
|
120
120
|
{
|
|
121
|
+
assert($this->from !== null);
|
|
121
122
|
return $context->format(
|
|
122
123
|
'$this->createTemplate(%raw, %node? + $this->params, "include")->renderToContentType(%raw, %raw) %line;',
|
|
123
124
|
$context->ensureString($this->from, 'Template name'),
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\Php\Expression\ArrayNode;
|
|
@@ -19,7 +17,7 @@ use Latte\Compiler\Tag;
|
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
|
-
* {include
|
|
20
|
+
* {include 'file.latte' [with blocks]}
|
|
23
21
|
*/
|
|
24
22
|
class IncludeFileNode extends StatementNode
|
|
25
23
|
{
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -19,7 +17,8 @@ use Latte\Compiler\Tag;
|
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
|
-
* {iterateWhile $cond}
|
|
20
|
+
* {iterateWhile [$cond]} ... {/iterateWhile [$cond]}
|
|
21
|
+
* Groups consecutive items in {foreach} by condition.
|
|
23
22
|
*/
|
|
24
23
|
class IterateWhileNode extends StatementNode
|
|
25
24
|
{
|
|
@@ -30,11 +29,11 @@ class IterateWhileNode extends StatementNode
|
|
|
30
29
|
public bool $postTest;
|
|
31
30
|
|
|
32
31
|
|
|
33
|
-
/** @return \Generator<int, ?
|
|
32
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
34
33
|
public static function create(Tag $tag): \Generator
|
|
35
34
|
{
|
|
36
35
|
$foreach = $tag->closestTag([ForeachNode::class])?->node;
|
|
37
|
-
if (!$foreach) {
|
|
36
|
+
if (!$foreach instanceof ForeachNode) {
|
|
38
37
|
throw new CompileException("Tag {{$tag->name}} must be inside {foreach} ... {/foreach}.", $tag->position);
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -48,6 +47,7 @@ class IterateWhileNode extends StatementNode
|
|
|
48
47
|
$node->value = $foreach->value;
|
|
49
48
|
[$node->content, $nextTag] = yield;
|
|
50
49
|
if ($node->postTest) {
|
|
50
|
+
assert($nextTag !== null);
|
|
51
51
|
$nextTag->expectArguments();
|
|
52
52
|
$node->condition = $nextTag->parser->parseExpression();
|
|
53
53
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -17,10 +15,8 @@ use Latte\Compiler\Tag;
|
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
|
-
* {breakIf
|
|
21
|
-
* {continueIf
|
|
22
|
-
* {skipIf ...}
|
|
23
|
-
* {exitIf ...}
|
|
18
|
+
* {breakIf $cond}, {continueIf $cond}, {skipIf $cond}, {exitIf $cond}
|
|
19
|
+
* Note: {skipIf} is like {continueIf} but doesn't increment $iterator->counter.
|
|
24
20
|
*/
|
|
25
21
|
class JumpNode extends StatementNode
|
|
26
22
|
{
|
|
@@ -50,7 +46,7 @@ class JumpNode extends StatementNode
|
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
$last = $parent?->prefix === Tag::PrefixNone
|
|
53
|
-
? $parent->htmlElement
|
|
49
|
+
? $parent->htmlElement?->parent
|
|
54
50
|
: $parent?->htmlElement;
|
|
55
51
|
$el = $tag->htmlElement;
|
|
56
52
|
while ($el && $el !== $last) {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte;
|
|
@@ -19,7 +17,7 @@ use function is_array;
|
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
|
-
* n:attr="
|
|
20
|
+
* <div n:attr="class => $class, id => $id">
|
|
23
21
|
*/
|
|
24
22
|
final class NAttrNode extends StatementNode
|
|
25
23
|
{
|
|
@@ -43,7 +41,7 @@ final class NAttrNode extends StatementNode
|
|
|
43
41
|
$this->args,
|
|
44
42
|
self::class,
|
|
45
43
|
$context->getEscaper()->getContentType() === Latte\ContentType::Xml,
|
|
46
|
-
$context->
|
|
44
|
+
$context->hasFeature(Latte\Feature::MigrationWarnings) ?: null,
|
|
47
45
|
$this->position,
|
|
48
46
|
);
|
|
49
47
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -17,7 +15,7 @@ use Latte\Compiler\Tag;
|
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
|
-
* n:class="
|
|
18
|
+
* <div n:class="$isActive ? active, highlight">
|
|
21
19
|
*/
|
|
22
20
|
final class NClassNode extends StatementNode
|
|
23
21
|
{
|
|
@@ -26,6 +24,7 @@ final class NClassNode extends StatementNode
|
|
|
26
24
|
|
|
27
25
|
public static function create(Tag $tag): static
|
|
28
26
|
{
|
|
27
|
+
assert($tag->htmlElement !== null);
|
|
29
28
|
if ($tag->htmlElement->getAttribute('class')) {
|
|
30
29
|
throw new CompileException('It is not possible to combine class with n:class.', $tag->position);
|
|
31
30
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -21,7 +19,8 @@ use Latte\Compiler\Tag;
|
|
|
21
19
|
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
|
-
* n:
|
|
22
|
+
* <div n:if="$cond"> ... <div n:else>
|
|
23
|
+
* <div n:if="$cond"> ... <div n:elseif="$cond2">
|
|
25
24
|
*/
|
|
26
25
|
final class NElseNode extends StatementNode
|
|
27
26
|
{
|
|
@@ -29,7 +28,7 @@ final class NElseNode extends StatementNode
|
|
|
29
28
|
public ?ExpressionNode $condition = null;
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
/** @return \Generator<int, ?
|
|
31
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
33
32
|
public static function create(Tag $tag): \Generator
|
|
34
33
|
{
|
|
35
34
|
$node = $tag->node = new static;
|
|
@@ -69,6 +68,10 @@ final class NElseNode extends StatementNode
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
|
|
71
|
+
/**
|
|
72
|
+
* @param AreaNode[] $children
|
|
73
|
+
* @return AreaNode[]
|
|
74
|
+
*/
|
|
72
75
|
private static function processFragment(array $children): array
|
|
73
76
|
{
|
|
74
77
|
$currentNode = null;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -18,18 +16,20 @@ use function preg_match;
|
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* n:tag="
|
|
19
|
+
* <div n:tag="$useSpan ? span">
|
|
22
20
|
*/
|
|
23
21
|
final class NTagNode extends StatementNode
|
|
24
22
|
{
|
|
25
23
|
public static function create(Tag $tag): void
|
|
26
24
|
{
|
|
25
|
+
assert($tag->htmlElement !== null);
|
|
27
26
|
if (preg_match('(style$|script$)iA', $tag->htmlElement->name)) {
|
|
28
27
|
throw new CompileException('Attribute n:tag is not allowed in <script> or <style>', $tag->position);
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
$tag->expectArguments();
|
|
32
31
|
$tag->htmlElement->dynamicTag ??= new TagNode($tag->htmlElement);
|
|
32
|
+
assert($tag->htmlElement->dynamicTag instanceof TagNode);
|
|
33
33
|
$tag->htmlElement->dynamicTag->name = $tag->parser->parseExpression();
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -23,7 +21,8 @@ use function is_string;
|
|
|
23
21
|
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
|
-
* {parameters [
|
|
24
|
+
* {parameters [Type] $name [= default], ...}
|
|
25
|
+
* Declares and filters template parameters.
|
|
27
26
|
*/
|
|
28
27
|
class ParametersNode extends StatementNode
|
|
29
28
|
{
|
|
@@ -43,6 +42,7 @@ class ParametersNode extends StatementNode
|
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
|
|
45
|
+
/** @return ParameterNode[] */
|
|
46
46
|
private static function parseParameters(Tag $tag): array
|
|
47
47
|
{
|
|
48
48
|
$stream = $tag->parser->stream;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\StatementNode;
|
|
@@ -16,7 +14,7 @@ use function preg_match, trim;
|
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
|
-
* {php
|
|
17
|
+
* {php code} (requires RawPhpExtension)
|
|
20
18
|
*/
|
|
21
19
|
class RawPhpNode extends StatementNode
|
|
22
20
|
{
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\CompileException;
|
|
@@ -17,6 +15,7 @@ use Latte\Compiler\Tag;
|
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* {rollback}
|
|
18
|
+
* Discards {try} block output and jumps to {else}.
|
|
20
19
|
*/
|
|
21
20
|
class RollbackNode extends StatementNode
|
|
22
21
|
{
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This file is part of the Latte (https://latte.nette.org)
|
|
5
5
|
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
8
|
namespace Latte\Essential\Nodes;
|
|
11
9
|
|
|
12
10
|
use Latte\Compiler\Nodes\AreaNode;
|
|
@@ -17,14 +15,15 @@ use Latte\ContentType;
|
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
|
-
* {spaceless}
|
|
18
|
+
* {spaceless} ... {/spaceless}
|
|
19
|
+
* Removes whitespace between HTML tags.
|
|
21
20
|
*/
|
|
22
21
|
class SpacelessNode extends StatementNode
|
|
23
22
|
{
|
|
24
23
|
public AreaNode $content;
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
/** @return \Generator<int, ?
|
|
26
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
28
27
|
public static function create(Tag $tag): \Generator
|
|
29
28
|
{
|
|
30
29
|
$node = $tag->node = new static;
|