@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;
|
|
11
9
|
|
|
12
10
|
use Latte;
|
|
@@ -30,7 +28,7 @@ final class Filters
|
|
|
30
28
|
/**
|
|
31
29
|
* Converts HTML to plain text.
|
|
32
30
|
*/
|
|
33
|
-
public static function stripHtml(FilterInfo $info, $s): string
|
|
31
|
+
public static function stripHtml(FilterInfo $info, string|Stringable|null $s): string
|
|
34
32
|
{
|
|
35
33
|
$info->validate([null, 'html', 'html/attr', 'xml', 'xml/attr'], __FUNCTION__);
|
|
36
34
|
$info->contentType = ContentType::Text;
|
|
@@ -41,7 +39,7 @@ final class Filters
|
|
|
41
39
|
/**
|
|
42
40
|
* Removes tags from HTML (but remains HTML entities).
|
|
43
41
|
*/
|
|
44
|
-
public static function stripTags(FilterInfo $info, $s): string
|
|
42
|
+
public static function stripTags(FilterInfo $info, string|Stringable|null $s): string
|
|
45
43
|
{
|
|
46
44
|
$info->contentType ??= ContentType::Html;
|
|
47
45
|
$info->validate(['html', 'html/attr', 'xml', 'xml/attr'], __FUNCTION__);
|
|
@@ -149,6 +147,7 @@ final class Filters
|
|
|
149
147
|
|
|
150
148
|
/**
|
|
151
149
|
* Splits a string by a string.
|
|
150
|
+
* @return list<string>
|
|
152
151
|
*/
|
|
153
152
|
public static function explode(string $value, string $separator = ''): array
|
|
154
153
|
{
|
|
@@ -161,7 +160,7 @@ final class Filters
|
|
|
161
160
|
/**
|
|
162
161
|
* Repeats text.
|
|
163
162
|
*/
|
|
164
|
-
public static function repeat(FilterInfo $info, $s, int $count): string
|
|
163
|
+
public static function repeat(FilterInfo $info, string|Stringable|null $s, int $count): string
|
|
165
164
|
{
|
|
166
165
|
return str_repeat((string) $s, $count);
|
|
167
166
|
}
|
|
@@ -287,15 +286,16 @@ final class Filters
|
|
|
287
286
|
|
|
288
287
|
/**
|
|
289
288
|
* Performs a search and replace.
|
|
289
|
+
* @param string|array<string, string>|array<string> $search
|
|
290
|
+
* @param string|array<string>|null $replace
|
|
290
291
|
*/
|
|
291
292
|
public static function replace(
|
|
292
293
|
FilterInfo $info,
|
|
293
|
-
string
|
|
294
|
+
string $subject,
|
|
294
295
|
string|array $search,
|
|
295
296
|
string|array|null $replace = null,
|
|
296
297
|
): string
|
|
297
298
|
{
|
|
298
|
-
$subject = (string) $subject;
|
|
299
299
|
if (is_array($search)) {
|
|
300
300
|
if (is_array($replace)) {
|
|
301
301
|
return strtr($subject, array_combine($search, $replace));
|
|
@@ -316,7 +316,7 @@ final class Filters
|
|
|
316
316
|
public static function replaceRe(string $subject, string $pattern, string $replacement = ''): string
|
|
317
317
|
{
|
|
318
318
|
$res = preg_replace($pattern, $replacement, $subject);
|
|
319
|
-
if (preg_last_error()) {
|
|
319
|
+
if (preg_last_error() || $res === null) {
|
|
320
320
|
throw new Latte\RuntimeException(preg_last_error_msg());
|
|
321
321
|
}
|
|
322
322
|
|
|
@@ -329,15 +329,23 @@ final class Filters
|
|
|
329
329
|
*/
|
|
330
330
|
public static function dataStream(string $data, ?string $type = null): string
|
|
331
331
|
{
|
|
332
|
-
$type
|
|
332
|
+
if ($type === null) {
|
|
333
|
+
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
|
334
|
+
if ($finfo) {
|
|
335
|
+
$type = finfo_buffer($finfo, $data) ?: null;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
333
338
|
return 'data:' . ($type ? "$type;" : '') . 'base64,' . base64_encode($data);
|
|
334
339
|
}
|
|
335
340
|
|
|
336
341
|
|
|
342
|
+
/**
|
|
343
|
+
* Converts newlines to HTML <br> tags.
|
|
344
|
+
*/
|
|
337
345
|
public static function breaklines(string|Stringable|null $s): Html
|
|
338
346
|
{
|
|
339
347
|
$s = htmlspecialchars((string) $s, ENT_NOQUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
|
340
|
-
return new Html(nl2br($s, false));
|
|
348
|
+
return new Html(nl2br($s, use_xhtml: false));
|
|
341
349
|
}
|
|
342
350
|
|
|
343
351
|
|
|
@@ -349,7 +357,7 @@ final class Filters
|
|
|
349
357
|
$s = (string) $s;
|
|
350
358
|
return match (true) {
|
|
351
359
|
extension_loaded('mbstring') => mb_substr($s, $start, $length, 'UTF-8'),
|
|
352
|
-
extension_loaded('iconv') => iconv_substr($s, $start, $length, 'UTF-8'),
|
|
360
|
+
extension_loaded('iconv') => (string) iconv_substr($s, $start, $length, 'UTF-8'),
|
|
353
361
|
default => throw new Latte\RuntimeException("Filter |substr requires 'mbstring' or 'iconv' extension."),
|
|
354
362
|
};
|
|
355
363
|
}
|
|
@@ -381,7 +389,7 @@ final class Filters
|
|
|
381
389
|
/**
|
|
382
390
|
* Convert to lower case.
|
|
383
391
|
*/
|
|
384
|
-
public static function lower($s): string
|
|
392
|
+
public static function lower(string|Stringable|null $s): string
|
|
385
393
|
{
|
|
386
394
|
return mb_strtolower((string) $s, 'UTF-8');
|
|
387
395
|
}
|
|
@@ -390,7 +398,7 @@ final class Filters
|
|
|
390
398
|
/**
|
|
391
399
|
* Convert to upper case.
|
|
392
400
|
*/
|
|
393
|
-
public static function upper($s): string
|
|
401
|
+
public static function upper(string|Stringable|null $s): string
|
|
394
402
|
{
|
|
395
403
|
return mb_strtoupper((string) $s, 'UTF-8');
|
|
396
404
|
}
|
|
@@ -399,7 +407,7 @@ final class Filters
|
|
|
399
407
|
/**
|
|
400
408
|
* Convert first character to lower case.
|
|
401
409
|
*/
|
|
402
|
-
public static function firstLower($s): string
|
|
410
|
+
public static function firstLower(string|Stringable|null $s): string
|
|
403
411
|
{
|
|
404
412
|
$s = (string) $s;
|
|
405
413
|
return self::lower(self::substring($s, 0, 1)) . self::substring($s, 1);
|
|
@@ -409,7 +417,7 @@ final class Filters
|
|
|
409
417
|
/**
|
|
410
418
|
* Convert first character to upper case.
|
|
411
419
|
*/
|
|
412
|
-
public static function firstUpper($s): string
|
|
420
|
+
public static function firstUpper(string|Stringable|null $s): string
|
|
413
421
|
{
|
|
414
422
|
$s = (string) $s;
|
|
415
423
|
return self::upper(self::substring($s, 0, 1)) . self::substring($s, 1);
|
|
@@ -419,7 +427,7 @@ final class Filters
|
|
|
419
427
|
/**
|
|
420
428
|
* Capitalize string.
|
|
421
429
|
*/
|
|
422
|
-
public static function capitalize($s): string
|
|
430
|
+
public static function capitalize(string|Stringable|null $s): string
|
|
423
431
|
{
|
|
424
432
|
return mb_convert_case((string) $s, MB_CASE_TITLE, 'UTF-8');
|
|
425
433
|
}
|
|
@@ -427,10 +435,11 @@ final class Filters
|
|
|
427
435
|
|
|
428
436
|
/**
|
|
429
437
|
* Returns length of string or iterable.
|
|
438
|
+
* @param array<mixed>|\Countable|\Traversable<mixed>|string $val
|
|
430
439
|
*/
|
|
431
440
|
public static function length(array|\Countable|\Traversable|string $val): int
|
|
432
441
|
{
|
|
433
|
-
if (
|
|
442
|
+
if (is_countable($val)) {
|
|
434
443
|
return count($val);
|
|
435
444
|
} elseif ($val instanceof \Traversable) {
|
|
436
445
|
return iterator_count($val);
|
|
@@ -444,7 +453,7 @@ final class Filters
|
|
|
444
453
|
{
|
|
445
454
|
return match (true) {
|
|
446
455
|
extension_loaded('mbstring') => mb_strlen($s, 'UTF-8'),
|
|
447
|
-
extension_loaded('iconv') => iconv_strlen($s, 'UTF-8'),
|
|
456
|
+
extension_loaded('iconv') => (int) iconv_strlen($s, 'UTF-8'),
|
|
448
457
|
default => strlen(@utf8_decode($s)), // deprecated
|
|
449
458
|
};
|
|
450
459
|
}
|
|
@@ -457,7 +466,7 @@ final class Filters
|
|
|
457
466
|
{
|
|
458
467
|
$charlist = preg_quote($charlist, '#');
|
|
459
468
|
$s = preg_replace('#^[' . $charlist . ']+|[' . $charlist . ']+$#Du', '', (string) $s);
|
|
460
|
-
if (preg_last_error()) {
|
|
469
|
+
if (preg_last_error() || $s === null) {
|
|
461
470
|
throw new Latte\RuntimeException(preg_last_error_msg());
|
|
462
471
|
}
|
|
463
472
|
|
|
@@ -468,7 +477,7 @@ final class Filters
|
|
|
468
477
|
/**
|
|
469
478
|
* Pad a string to a certain length with another string.
|
|
470
479
|
*/
|
|
471
|
-
public static function padLeft($s, int $length, string $append = ' '): string
|
|
480
|
+
public static function padLeft(string|Stringable|null $s, int $length, string $append = ' '): string
|
|
472
481
|
{
|
|
473
482
|
$s = (string) $s;
|
|
474
483
|
$length = max(0, $length - self::strLength($s));
|
|
@@ -480,7 +489,7 @@ final class Filters
|
|
|
480
489
|
/**
|
|
481
490
|
* Pad a string to a certain length with another string.
|
|
482
491
|
*/
|
|
483
|
-
public static function padRight($s, int $length, string $append = ' '): string
|
|
492
|
+
public static function padRight(string|Stringable|null $s, int $length, string $append = ' '): string
|
|
484
493
|
{
|
|
485
494
|
$s = (string) $s;
|
|
486
495
|
$length = max(0, $length - self::strLength($s));
|
|
@@ -491,23 +500,25 @@ final class Filters
|
|
|
491
500
|
|
|
492
501
|
/**
|
|
493
502
|
* Reverses string or array.
|
|
503
|
+
* @template K
|
|
504
|
+
* @template V
|
|
505
|
+
* @param iterable<K, V>|string $val
|
|
506
|
+
* @return ($val is string ? string : array<K, V>)
|
|
494
507
|
*/
|
|
495
508
|
public static function reverse(string|iterable $val, bool $preserveKeys = false): string|array
|
|
496
509
|
{
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
return array_reverse(iterator_to_array($val), $preserveKeys);
|
|
501
|
-
} else {
|
|
502
|
-
return iconv('UTF-32LE', 'UTF-8', strrev(iconv('UTF-8', 'UTF-32BE', (string) $val)));
|
|
503
|
-
}
|
|
510
|
+
return is_string($val)
|
|
511
|
+
? (string) iconv('UTF-32LE', 'UTF-8', strrev((string) iconv('UTF-8', 'UTF-32BE', $val)))
|
|
512
|
+
: array_reverse(iterator_to_array($val), $preserveKeys);
|
|
504
513
|
}
|
|
505
514
|
|
|
506
515
|
|
|
507
516
|
/**
|
|
508
517
|
* Chunks items by returning an array of arrays with the given number of items.
|
|
518
|
+
* @param iterable<mixed> $list
|
|
519
|
+
* @return \Generator<int, array<mixed>>
|
|
509
520
|
*/
|
|
510
|
-
public static function batch(iterable $list, int $length, $rest = null): \Generator
|
|
521
|
+
public static function batch(iterable $list, int $length, mixed $rest = null): \Generator
|
|
511
522
|
{
|
|
512
523
|
$batch = [];
|
|
513
524
|
foreach ($list as $key => $value) {
|
|
@@ -535,6 +546,9 @@ final class Filters
|
|
|
535
546
|
* @template K
|
|
536
547
|
* @template V
|
|
537
548
|
* @param iterable<K, V> $data
|
|
549
|
+
* @param ?(\Closure(V, V): int) $comparison
|
|
550
|
+
* @param string|int|(\Closure(V): mixed)|null $by
|
|
551
|
+
* @param string|int|(\Closure(K): mixed)|bool $byKey
|
|
538
552
|
* @return iterable<K, V>
|
|
539
553
|
*/
|
|
540
554
|
public function sort(
|
|
@@ -587,6 +601,7 @@ final class Filters
|
|
|
587
601
|
* @template K
|
|
588
602
|
* @template V
|
|
589
603
|
* @param iterable<K, V> $data
|
|
604
|
+
* @param string|int|(\Closure(V, K): mixed) $by
|
|
590
605
|
* @return iterable<iterable<K, V>>
|
|
591
606
|
*/
|
|
592
607
|
public static function group(iterable $data, string|int|\Closure $by): iterable
|
|
@@ -597,7 +612,7 @@ final class Filters
|
|
|
597
612
|
foreach ($data as $k => $v) {
|
|
598
613
|
$groupKey = $fn($v, $k);
|
|
599
614
|
if (!$groups || $prevKey !== $groupKey) {
|
|
600
|
-
$index = array_search($groupKey, $keys, true);
|
|
615
|
+
$index = array_search($groupKey, $keys, strict: true);
|
|
601
616
|
if ($index === false) {
|
|
602
617
|
$index = count($keys);
|
|
603
618
|
$keys[$index] = $groupKey;
|
|
@@ -648,6 +663,7 @@ final class Filters
|
|
|
648
663
|
|
|
649
664
|
/**
|
|
650
665
|
* Generates URL-encoded query string
|
|
666
|
+
* @param string|array<mixed> $data
|
|
651
667
|
*/
|
|
652
668
|
public static function query(string|array $data): string
|
|
653
669
|
{
|
|
@@ -686,6 +702,8 @@ final class Filters
|
|
|
686
702
|
|
|
687
703
|
/**
|
|
688
704
|
* Returns the first element in an array or character in a string, or null if none.
|
|
705
|
+
* @param string|iterable<mixed> $value
|
|
706
|
+
* @return ($value is string ? string : mixed)
|
|
689
707
|
*/
|
|
690
708
|
public static function first(string|iterable $value): mixed
|
|
691
709
|
{
|
|
@@ -703,6 +721,8 @@ final class Filters
|
|
|
703
721
|
|
|
704
722
|
/**
|
|
705
723
|
* Returns the last element in an array or character in a string, or null if none.
|
|
724
|
+
* @param string|array<mixed> $value
|
|
725
|
+
* @return ($value is string ? string : mixed)
|
|
706
726
|
*/
|
|
707
727
|
public static function last(string|array $value): mixed
|
|
708
728
|
{
|
|
@@ -714,6 +734,8 @@ final class Filters
|
|
|
714
734
|
|
|
715
735
|
/**
|
|
716
736
|
* Extracts a slice of an array or string.
|
|
737
|
+
* @param string|array<mixed> $value
|
|
738
|
+
* @return ($value is string ? string : array<mixed>)
|
|
717
739
|
*/
|
|
718
740
|
public static function slice(
|
|
719
741
|
string|array $value,
|
|
@@ -728,18 +750,27 @@ final class Filters
|
|
|
728
750
|
}
|
|
729
751
|
|
|
730
752
|
|
|
753
|
+
/**
|
|
754
|
+
* Rounds number to specified precision.
|
|
755
|
+
*/
|
|
731
756
|
public static function round(float $value, int $precision = 0): float
|
|
732
757
|
{
|
|
733
758
|
return round($value, $precision);
|
|
734
759
|
}
|
|
735
760
|
|
|
736
761
|
|
|
762
|
+
/**
|
|
763
|
+
* Rounds number down to specified precision.
|
|
764
|
+
*/
|
|
737
765
|
public static function floor(float $value, int $precision = 0): float
|
|
738
766
|
{
|
|
739
767
|
return floor($value * 10 ** $precision) / 10 ** $precision;
|
|
740
768
|
}
|
|
741
769
|
|
|
742
770
|
|
|
771
|
+
/**
|
|
772
|
+
* Rounds number up to specified precision.
|
|
773
|
+
*/
|
|
743
774
|
public static function ceil(float $value, int $precision = 0): float
|
|
744
775
|
{
|
|
745
776
|
return ceil($value * 10 ** $precision) / 10 ** $precision;
|
|
@@ -748,6 +779,8 @@ final class Filters
|
|
|
748
779
|
|
|
749
780
|
/**
|
|
750
781
|
* Picks random element/char.
|
|
782
|
+
* @param string|array<mixed> $values
|
|
783
|
+
* @return ($values is string ? string : mixed)
|
|
751
784
|
*/
|
|
752
785
|
public static function random(string|array $values): mixed
|
|
753
786
|
{
|
|
@@ -764,7 +797,7 @@ final class Filters
|
|
|
764
797
|
/**
|
|
765
798
|
* Sanitizes string for use inside href attribute.
|
|
766
799
|
*/
|
|
767
|
-
public static function checkUrl($s): string
|
|
800
|
+
public static function checkUrl(mixed $s): string
|
|
768
801
|
{
|
|
769
802
|
$s = $s instanceof Latte\Runtime\HtmlStringable
|
|
770
803
|
? Latte\Runtime\HtmlHelpers::convertHtmlToText((string) $s)
|
|
@@ -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,8 @@ use Latte\Runtime\Template;
|
|
|
24
22
|
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
|
-
* {block [local]
|
|
25
|
+
* {block [local] name} ... {/block}
|
|
26
|
+
* {block|filter} ... {/block} (anonymous filter block)
|
|
28
27
|
*/
|
|
29
28
|
class BlockNode extends StatementNode
|
|
30
29
|
{
|
|
@@ -33,12 +32,13 @@ class BlockNode extends StatementNode
|
|
|
33
32
|
public AreaNode $content;
|
|
34
33
|
|
|
35
34
|
|
|
36
|
-
/** @return \Generator<int, ?
|
|
35
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
37
36
|
public static function create(Tag $tag, TemplateParser $parser): \Generator
|
|
38
37
|
{
|
|
39
38
|
$tag->outputMode = $tag::OutputRemoveIndentation;
|
|
40
39
|
$stream = $tag->parser->stream;
|
|
41
40
|
$node = $tag->node = new static;
|
|
41
|
+
$name = null;
|
|
42
42
|
|
|
43
43
|
if (!$stream->is('|', Token::End)) {
|
|
44
44
|
$layer = $tag->parser->tryConsumeTokenBeforeUnquotedString('local')
|
|
@@ -108,6 +108,7 @@ class BlockNode extends StatementNode
|
|
|
108
108
|
|
|
109
109
|
private function printStatic(PrintContext $context): string
|
|
110
110
|
{
|
|
111
|
+
assert($this->block !== null);
|
|
111
112
|
$this->modifier->escape = $this->modifier->escape || $context->getEscaper()->getState() === Escaper::HtmlAttribute;
|
|
112
113
|
$context->addBlock($this->block);
|
|
113
114
|
$this->block->content = $this->content->print($context); // must be compiled after is added
|
|
@@ -127,13 +128,14 @@ class BlockNode extends StatementNode
|
|
|
127
128
|
|
|
128
129
|
private function printDynamic(PrintContext $context): string
|
|
129
130
|
{
|
|
131
|
+
assert($this->block !== null);
|
|
130
132
|
$context->addBlock($this->block);
|
|
131
133
|
$this->block->content = $this->content->print($context); // must be compiled after is added
|
|
132
134
|
$escaper = $context->getEscaper();
|
|
133
135
|
$this->modifier->escape = $this->modifier->escape || $escaper->getState() === Escaper::HtmlAttribute;
|
|
134
136
|
|
|
135
137
|
return $context->format(
|
|
136
|
-
'$this->addBlock($ʟ_nm = %raw, %dump, [
|
|
138
|
+
'$this->addBlock($ʟ_nm = %raw, %dump, [$this->%raw(...)], %dump);
|
|
137
139
|
$this->renderBlock($ʟ_nm, get_defined_vars()'
|
|
138
140
|
. ($this->modifier->filters || $this->modifier->escape
|
|
139
141
|
? ', function ($s, $type) { $ʟ_fi = new LR\FilterInfo($type); return %modifyContent($s); }'
|
|
@@ -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\Tag;
|
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
|
-
* {capture $
|
|
21
|
+
* {capture $var} ... {/capture}
|
|
22
|
+
* Captures block output into variable.
|
|
24
23
|
*/
|
|
25
24
|
class CaptureNode extends StatementNode
|
|
26
25
|
{
|
|
@@ -29,7 +28,7 @@ class CaptureNode extends StatementNode
|
|
|
29
28
|
public AreaNode $content;
|
|
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
|
$tag->expectArguments();
|
|
@@ -37,7 +36,7 @@ class CaptureNode extends StatementNode
|
|
|
37
36
|
if (!$variable->isWritable()) {
|
|
38
37
|
$text = '';
|
|
39
38
|
$i = 0;
|
|
40
|
-
while ($token = $tag->parser->stream->
|
|
39
|
+
while ($token = $tag->parser->stream->tryPeek(--$i)) {
|
|
41
40
|
$text = $token->text . $text;
|
|
42
41
|
}
|
|
43
42
|
|
|
@@ -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,7 +16,8 @@ use Latte\ContentType;
|
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* {contentType
|
|
19
|
+
* {contentType html|xml|js|css|text|...}
|
|
20
|
+
* Switches escaping mode and optionally sends HTTP header.
|
|
22
21
|
*/
|
|
23
22
|
class ContentTypeNode extends StatementNode
|
|
24
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\Compiler\Nodes\Php;
|
|
@@ -17,7 +15,7 @@ use Latte\Helpers;
|
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
18
|
+
* Wrapper for custom function calls in Latte expressions.
|
|
21
19
|
*/
|
|
22
20
|
class CustomFunctionCallNode extends ExpressionNode
|
|
23
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\Php\ExpressionNode;
|
|
@@ -17,6 +15,7 @@ use Latte\Compiler\Tag;
|
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* {debugbreak [$cond]}
|
|
18
|
+
* Triggers debugger breakpoint.
|
|
20
19
|
*/
|
|
21
20
|
class DebugbreakNode 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\Block;
|
|
@@ -26,7 +24,8 @@ use function is_string;
|
|
|
26
24
|
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
|
-
* {define
|
|
27
|
+
* {define name($params)} ... {/define}
|
|
28
|
+
* Defines reusable block with parameters.
|
|
30
29
|
*/
|
|
31
30
|
class DefineNode extends StatementNode
|
|
32
31
|
{
|
|
@@ -34,7 +33,7 @@ class DefineNode extends StatementNode
|
|
|
34
33
|
public AreaNode $content;
|
|
35
34
|
|
|
36
35
|
|
|
37
|
-
/** @return \Generator<int, ?
|
|
36
|
+
/** @return \Generator<int, ?list<string>, array{AreaNode, ?Tag}, static> */
|
|
38
37
|
public static function create(Tag $tag, TemplateParser $parser): \Generator
|
|
39
38
|
{
|
|
40
39
|
$tag->expectArguments();
|
|
@@ -61,6 +60,7 @@ class DefineNode extends StatementNode
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
|
|
63
|
+
/** @return ParameterNode[] */
|
|
64
64
|
private static function parseParameters(Tag $tag): array
|
|
65
65
|
{
|
|
66
66
|
$stream = $tag->parser->stream;
|
|
@@ -114,7 +114,7 @@ class DefineNode extends StatementNode
|
|
|
114
114
|
$this->block->content = $this->content->print($context); // must be compiled after is added
|
|
115
115
|
|
|
116
116
|
return $context->format(
|
|
117
|
-
'$this->addBlock(%raw, %dump, [
|
|
117
|
+
'$this->addBlock(%raw, %dump, [$this->%raw(...)], %dump);',
|
|
118
118
|
$context->ensureString($this->block->name, 'Block name'),
|
|
119
119
|
$context->getEscaper()->export(),
|
|
120
120
|
$this->block->method,
|
|
@@ -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\ExpressionNode;
|
|
@@ -16,7 +14,8 @@ use Latte\Compiler\Tag;
|
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
|
-
* {do
|
|
17
|
+
* {do $expr}
|
|
18
|
+
* Executes expression without output.
|
|
20
19
|
*/
|
|
21
20
|
class DoNode 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\Php\ExpressionNode;
|
|
@@ -17,6 +15,7 @@ use Latte\Compiler\Tag;
|
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* {dump [$var]}
|
|
18
|
+
* Dumps variable or all variables to Tracy Bar.
|
|
20
19
|
*/
|
|
21
20
|
class DumpNode 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\CompileException;
|
|
@@ -23,7 +21,7 @@ use function count, preg_match;
|
|
|
23
21
|
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
|
-
* {embed
|
|
24
|
+
* {embed 'file.latte'|#block} ... {/embed}
|
|
27
25
|
*/
|
|
28
26
|
class EmbedNode extends StatementNode
|
|
29
27
|
{
|
|
@@ -34,7 +32,7 @@ class EmbedNode extends StatementNode
|
|
|
34
32
|
public int|string|null $layer;
|
|
35
33
|
|
|
36
34
|
|
|
37
|
-
/** @return \Generator<int, ?
|
|
35
|
+
/** @return \Generator<int, ?list<string>, array{FragmentNode, ?Tag}, static> */
|
|
38
36
|
public static function create(Tag $tag, TemplateParser $parser): \Generator
|
|
39
37
|
{
|
|
40
38
|
if ($tag->isNAttribute()) {
|
|
@@ -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,8 +17,8 @@ use Latte\Compiler\Tag;
|
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
|
-
* {extends
|
|
23
|
-
* {layout
|
|
20
|
+
* {extends 'parent.latte'}
|
|
21
|
+
* {layout 'layout.latte'}
|
|
24
22
|
*/
|
|
25
23
|
class ExtendsNode extends StatementNode
|
|
26
24
|
{
|