@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,381 @@
|
|
|
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\Runtime;
|
|
11
|
+
|
|
12
|
+
use Latte;
|
|
13
|
+
use Latte\Compiler\Escaper;
|
|
14
|
+
use Latte\Engine;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Template.
|
|
19
|
+
*/
|
|
20
|
+
class Template
|
|
21
|
+
{
|
|
22
|
+
use Latte\Strict;
|
|
23
|
+
|
|
24
|
+
public const
|
|
25
|
+
LayerTop = 0,
|
|
26
|
+
LayerSnippet = 'snippet',
|
|
27
|
+
LayerLocal = 'local';
|
|
28
|
+
|
|
29
|
+
public const ContentType = Latte\ContentType::Html;
|
|
30
|
+
|
|
31
|
+
public const Blocks = [];
|
|
32
|
+
|
|
33
|
+
/** global accumulators for intermediate results */
|
|
34
|
+
public \stdClass $global;
|
|
35
|
+
|
|
36
|
+
/** @var mixed[] @internal */
|
|
37
|
+
protected array $params = [];
|
|
38
|
+
|
|
39
|
+
protected FilterExecutor $filters;
|
|
40
|
+
|
|
41
|
+
/** @internal */
|
|
42
|
+
protected string|false|null $parentName = null;
|
|
43
|
+
|
|
44
|
+
/** @var mixed[][] */
|
|
45
|
+
protected array $varStack = [];
|
|
46
|
+
|
|
47
|
+
/** @var Block[][] */
|
|
48
|
+
protected array $blocks;
|
|
49
|
+
|
|
50
|
+
/** @var mixed[][] */
|
|
51
|
+
private array $blockStack = [];
|
|
52
|
+
|
|
53
|
+
private Engine $engine;
|
|
54
|
+
private string $name;
|
|
55
|
+
private ?Template $referringTemplate = null;
|
|
56
|
+
private ?string $referenceType = null;
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param mixed[] $params
|
|
61
|
+
* @param mixed[] $providers
|
|
62
|
+
*/
|
|
63
|
+
public function __construct(
|
|
64
|
+
Engine $engine,
|
|
65
|
+
array $params,
|
|
66
|
+
FilterExecutor $filters,
|
|
67
|
+
array $providers,
|
|
68
|
+
string $name,
|
|
69
|
+
) {
|
|
70
|
+
$this->engine = $engine;
|
|
71
|
+
$this->params = $params;
|
|
72
|
+
$this->filters = $filters;
|
|
73
|
+
$this->name = $name;
|
|
74
|
+
$this->global = (object) $providers;
|
|
75
|
+
$this->initBlockLayer(self::LayerTop);
|
|
76
|
+
$this->initBlockLayer(self::LayerLocal);
|
|
77
|
+
$this->initBlockLayer(self::LayerSnippet);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
public function getEngine(): Engine
|
|
82
|
+
{
|
|
83
|
+
return $this->engine;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
public function getName(): string
|
|
88
|
+
{
|
|
89
|
+
return $this->name;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Returns array of all parameters.
|
|
95
|
+
* @return mixed[]
|
|
96
|
+
*/
|
|
97
|
+
public function getParameters(): array
|
|
98
|
+
{
|
|
99
|
+
return $this->params;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @return string[]
|
|
105
|
+
*/
|
|
106
|
+
public function getBlockNames(int|string $layer = self::LayerTop): array
|
|
107
|
+
{
|
|
108
|
+
return array_keys($this->blocks[$layer] ?? []);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
public function getParentName(): ?string
|
|
113
|
+
{
|
|
114
|
+
return $this->parentName ?: null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
public function getReferringTemplate(): ?self
|
|
119
|
+
{
|
|
120
|
+
return $this->referringTemplate;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
public function getReferenceType(): ?string
|
|
125
|
+
{
|
|
126
|
+
return $this->referenceType;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Renders template.
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
public function render(?string $block = null): void
|
|
135
|
+
{
|
|
136
|
+
$params = $this->prepare();
|
|
137
|
+
|
|
138
|
+
if ($this->parentName === null && isset($this->global->coreParentFinder)) {
|
|
139
|
+
$this->parentName = ($this->global->coreParentFinder)($this);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
Filters::$xml = static::ContentType === Latte\ContentType::Xml;
|
|
143
|
+
|
|
144
|
+
if ($this->referenceType === 'import') {
|
|
145
|
+
if ($this->parentName) {
|
|
146
|
+
throw new Latte\RuntimeException('Imported template cannot use {extends} or {layout}, use {import}');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
} elseif ($this->parentName) { // extends
|
|
150
|
+
$this->params = $params;
|
|
151
|
+
$this->createTemplate($this->parentName, $params, 'extends')->render($block);
|
|
152
|
+
|
|
153
|
+
} elseif ($block !== null) { // single block rendering
|
|
154
|
+
$this->renderBlock($block, $this->params);
|
|
155
|
+
|
|
156
|
+
} else {
|
|
157
|
+
$this->main($params);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Renders template.
|
|
164
|
+
* @param mixed[] $params
|
|
165
|
+
* @internal
|
|
166
|
+
*/
|
|
167
|
+
public function createTemplate(string $name, array $params, string $referenceType): self
|
|
168
|
+
{
|
|
169
|
+
$name = $this->engine->getLoader()->getReferredName($name, $this->name);
|
|
170
|
+
$referred = $referenceType === 'sandbox'
|
|
171
|
+
? (clone $this->engine)->setSandboxMode()->createTemplate($name, $params)
|
|
172
|
+
: $this->engine->createTemplate($name, $params);
|
|
173
|
+
|
|
174
|
+
$referred->referringTemplate = $this;
|
|
175
|
+
$referred->referenceType = $referenceType;
|
|
176
|
+
$referred->global = $this->global;
|
|
177
|
+
|
|
178
|
+
if (in_array($referenceType, ['extends', 'includeblock', 'import', 'embed'], true)) {
|
|
179
|
+
foreach ($referred->blocks[self::LayerTop] as $nm => $block) {
|
|
180
|
+
$this->addBlock($nm, $block->contentType, $block->functions);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
$referred->blocks[self::LayerTop] = &$this->blocks[self::LayerTop];
|
|
184
|
+
|
|
185
|
+
$this->blocks[self::LayerSnippet] += $referred->blocks[self::LayerSnippet];
|
|
186
|
+
$referred->blocks[self::LayerSnippet] = &$this->blocks[self::LayerSnippet];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
($this->engine->probe)($referred);
|
|
190
|
+
return $referred;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @param string|\Closure|null $mod content-type name or modifier closure
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
public function renderToContentType(string|\Closure|null $mod, ?string $block = null): void
|
|
199
|
+
{
|
|
200
|
+
$this->filter(
|
|
201
|
+
function () use ($block) { $this->render($block); },
|
|
202
|
+
$mod,
|
|
203
|
+
static::ContentType,
|
|
204
|
+
"'$this->name'",
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
/** @return mixed[] */
|
|
210
|
+
public function prepare(): array
|
|
211
|
+
{
|
|
212
|
+
return $this->params;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
/** @param mixed[] $params */
|
|
217
|
+
public function main(array $params): void
|
|
218
|
+
{
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
/********************* blocks ****************d*g**/
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Renders block.
|
|
227
|
+
* @param mixed[] $params
|
|
228
|
+
* @param string|\Closure|null $mod content-type name or modifier closure
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
231
|
+
public function renderBlock(
|
|
232
|
+
string $name,
|
|
233
|
+
array $params,
|
|
234
|
+
string|\Closure|null $mod = null,
|
|
235
|
+
int|string|null $layer = null,
|
|
236
|
+
): void {
|
|
237
|
+
$block = $layer
|
|
238
|
+
? ($this->blocks[$layer][$name] ?? null)
|
|
239
|
+
: ($this->blocks[self::LayerLocal][$name] ?? $this->blocks[self::LayerTop][$name] ?? null);
|
|
240
|
+
|
|
241
|
+
if (!$block) {
|
|
242
|
+
$hint = $layer && ($t = Latte\Helpers::getSuggestion($this->getBlockNames($layer), $name))
|
|
243
|
+
? ", did you mean '$t'?"
|
|
244
|
+
: '.';
|
|
245
|
+
$name = $layer ? "$layer $name" : $name;
|
|
246
|
+
throw new Latte\RuntimeException("Cannot include undefined block '$name'$hint");
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
$this->filter(
|
|
250
|
+
function () use ($block, $params): void { reset($block->functions)($params); },
|
|
251
|
+
$mod,
|
|
252
|
+
$block->contentType,
|
|
253
|
+
"block $name",
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Renders parent block.
|
|
260
|
+
* @param mixed[] $params
|
|
261
|
+
* @internal
|
|
262
|
+
*/
|
|
263
|
+
public function renderBlockParent(string $name, array $params): void
|
|
264
|
+
{
|
|
265
|
+
$block = $this->blocks[self::LayerLocal][$name] ?? $this->blocks[self::LayerTop][$name] ?? null;
|
|
266
|
+
if (!$block || ($function = next($block->functions)) === false) {
|
|
267
|
+
throw new Latte\RuntimeException("Cannot include undefined parent block '$name'.");
|
|
268
|
+
}
|
|
269
|
+
$function($params);
|
|
270
|
+
prev($block->functions);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Creates block if doesn't exist and checks if content type is the same.
|
|
276
|
+
* @param callable[] $functions
|
|
277
|
+
* @internal
|
|
278
|
+
*/
|
|
279
|
+
protected function addBlock(
|
|
280
|
+
string $name,
|
|
281
|
+
string $contentType,
|
|
282
|
+
array $functions,
|
|
283
|
+
int|string|null $layer = null,
|
|
284
|
+
): void {
|
|
285
|
+
$block = &$this->blocks[$layer ?? self::LayerTop][$name];
|
|
286
|
+
$block ??= new Block;
|
|
287
|
+
if ($block->contentType === null) {
|
|
288
|
+
$block->contentType = $contentType;
|
|
289
|
+
|
|
290
|
+
} elseif (!Escaper::getConvertor($contentType, $block->contentType)) {
|
|
291
|
+
throw new Latte\RuntimeException(sprintf(
|
|
292
|
+
"Overridden block $name with content type %s by incompatible type %s.",
|
|
293
|
+
strtoupper($contentType),
|
|
294
|
+
strtoupper($block->contentType),
|
|
295
|
+
));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
$block->functions = array_merge($block->functions, $functions);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* @param string|\Closure|null $mod content-type name or modifier closure
|
|
304
|
+
*/
|
|
305
|
+
private function filter(callable $function, string|\Closure|null $mod, string $contentType, string $name): void
|
|
306
|
+
{
|
|
307
|
+
if ($mod === null || $mod === $contentType) {
|
|
308
|
+
$function();
|
|
309
|
+
|
|
310
|
+
} elseif ($mod instanceof \Closure) {
|
|
311
|
+
echo $mod($this->capture($function), $contentType);
|
|
312
|
+
|
|
313
|
+
} elseif ($filter = Escaper::getConvertor($contentType, $mod)) {
|
|
314
|
+
echo $filter($this->capture($function));
|
|
315
|
+
|
|
316
|
+
} else {
|
|
317
|
+
throw new Latte\RuntimeException(sprintf(
|
|
318
|
+
"Including $name with content type %s into incompatible type %s.",
|
|
319
|
+
strtoupper($contentType),
|
|
320
|
+
strtoupper($mod),
|
|
321
|
+
));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Captures output to string.
|
|
328
|
+
* @internal
|
|
329
|
+
*/
|
|
330
|
+
public function capture(callable $function): string
|
|
331
|
+
{
|
|
332
|
+
try {
|
|
333
|
+
ob_start(fn() => '');
|
|
334
|
+
$function();
|
|
335
|
+
return ob_get_clean();
|
|
336
|
+
} catch (\Throwable $e) {
|
|
337
|
+
ob_end_clean();
|
|
338
|
+
throw $e;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
private function initBlockLayer(int|string $staticId, ?int $destId = null): void
|
|
344
|
+
{
|
|
345
|
+
$destId ??= $staticId;
|
|
346
|
+
$this->blocks[$destId] = [];
|
|
347
|
+
foreach (static::Blocks[$staticId] ?? [] as $nm => $info) {
|
|
348
|
+
[$method, $contentType] = is_array($info) ? $info : [$info, static::ContentType];
|
|
349
|
+
$this->addBlock($nm, $contentType, [[$this, $method]], $destId);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
protected function enterBlockLayer(int $staticId, array $vars): void
|
|
355
|
+
{
|
|
356
|
+
$this->blockStack[] = $this->blocks[self::LayerTop];
|
|
357
|
+
$this->initBlockLayer($staticId, self::LayerTop);
|
|
358
|
+
$this->varStack[] = $vars;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
protected function copyBlockLayer(): void
|
|
363
|
+
{
|
|
364
|
+
foreach (end($this->blockStack) as $nm => $block) {
|
|
365
|
+
$this->addBlock($nm, $block->contentType, $block->functions);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
protected function leaveBlockLayer(): void
|
|
371
|
+
{
|
|
372
|
+
$this->blocks[self::LayerTop] = array_pop($this->blockStack);
|
|
373
|
+
array_pop($this->varStack);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
public function hasBlock(string $name): bool
|
|
378
|
+
{
|
|
379
|
+
return isset($this->blocks[self::LayerLocal][$name]) || isset($this->blocks[self::LayerTop][$name]);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FunctionCallNode extends Expression\FunctionCallNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(Expression\FunctionCallNode $from)
|
|
19
|
+
{
|
|
20
|
+
parent::__construct($from->name, $from->args, $from->position);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public function print(PrintContext $context): string
|
|
25
|
+
{
|
|
26
|
+
return '$this->global->sandbox->call('
|
|
27
|
+
. $context->memberAsString($this->name) . ', '
|
|
28
|
+
. Expression\ArrayNode::fromArguments($this->args)->print($context) . ')';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FunctionCallableNode extends Expression\FunctionCallableNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(Expression\FunctionCallableNode $from)
|
|
19
|
+
{
|
|
20
|
+
parent::__construct($from->name, $from->position);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public function print(PrintContext $context): string
|
|
25
|
+
{
|
|
26
|
+
return '$this->global->sandbox->closure('
|
|
27
|
+
. $context->memberAsString($this->name) . ')';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MethodCallNode extends Expression\MethodCallNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(Expression\MethodCallNode $from)
|
|
19
|
+
{
|
|
20
|
+
parent::__construct($from->object, $from->name, $from->args, $from->nullsafe, $from->position);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public function print(PrintContext $context): string
|
|
25
|
+
{
|
|
26
|
+
return '$this->global->sandbox->callMethod('
|
|
27
|
+
. $this->object->print($context) . ', '
|
|
28
|
+
. $context->memberAsString($this->name) . ', '
|
|
29
|
+
. Expression\ArrayNode::fromArguments($this->args)->print($context)
|
|
30
|
+
. ', ' . var_export($this->nullsafe, true) . ')';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MethodCallableNode extends Expression\MethodCallableNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(Expression\MethodCallableNode $from)
|
|
19
|
+
{
|
|
20
|
+
parent::__construct($from->object, $from->name, $from->position);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public function print(PrintContext $context): string
|
|
25
|
+
{
|
|
26
|
+
return '$this->global->sandbox->closure(['
|
|
27
|
+
. $this->object->print($context) . ', '
|
|
28
|
+
. $context->memberAsString($this->name) . '])';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PropertyFetchNode extends Expression\PropertyFetchNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(Expression\PropertyFetchNode $from)
|
|
19
|
+
{
|
|
20
|
+
parent::__construct($from->object, $from->name, $from->nullsafe, $from->position);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public function print(PrintContext $context): string
|
|
25
|
+
{
|
|
26
|
+
return '$this->global->sandbox->prop('
|
|
27
|
+
. $this->object->print($context) . ', '
|
|
28
|
+
. $context->memberAsString($this->name) . ')'
|
|
29
|
+
. ($this->nullsafe ? '?->' : '->')
|
|
30
|
+
. $context->objectProperty($this->name);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression\ArrayNode;
|
|
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
|
+
* {sandbox "file" [,] [params]}
|
|
21
|
+
*/
|
|
22
|
+
class SandboxNode extends StatementNode
|
|
23
|
+
{
|
|
24
|
+
public ExpressionNode $file;
|
|
25
|
+
public ArrayNode $args;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
public static function create(Tag $tag): static
|
|
29
|
+
{
|
|
30
|
+
$tag->outputMode = $tag::OutputRemoveIndentation;
|
|
31
|
+
$tag->expectArguments();
|
|
32
|
+
$node = new static;
|
|
33
|
+
$node->file = $tag->parser->parseUnquotedStringOrExpression();
|
|
34
|
+
$tag->parser->stream->tryConsume(',');
|
|
35
|
+
$node->args = $tag->parser->parseArguments();
|
|
36
|
+
return $node;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
public function print(PrintContext $context): string
|
|
41
|
+
{
|
|
42
|
+
return $context->format(
|
|
43
|
+
<<<'XX'
|
|
44
|
+
ob_start(fn() => '');
|
|
45
|
+
try {
|
|
46
|
+
$this->createTemplate(%node, %node, 'sandbox')->renderToContentType(%dump) %line;
|
|
47
|
+
echo ob_get_clean();
|
|
48
|
+
} catch (\Throwable $ʟ_e) {
|
|
49
|
+
if (isset($this->global->coreExceptionHandler)) {
|
|
50
|
+
ob_end_clean();
|
|
51
|
+
($this->global->coreExceptionHandler)($ʟ_e, $this);
|
|
52
|
+
} else {
|
|
53
|
+
echo ob_get_clean();
|
|
54
|
+
throw $ʟ_e;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
XX,
|
|
60
|
+
$this->file,
|
|
61
|
+
$this->args,
|
|
62
|
+
$context->getEscaper()->export(),
|
|
63
|
+
$this->position,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
public function &getIterator(): \Generator
|
|
69
|
+
{
|
|
70
|
+
yield $this->file;
|
|
71
|
+
yield $this->args;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class StaticCallNode extends Expression\StaticCallNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(Expression\StaticCallNode $from)
|
|
19
|
+
{
|
|
20
|
+
parent::__construct($from->class, $from->name, $from->args, $from->position);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public function print(PrintContext $context): string
|
|
25
|
+
{
|
|
26
|
+
return '$this->global->sandbox->call(['
|
|
27
|
+
. $context->memberAsString($this->class) . ', '
|
|
28
|
+
. $context->memberAsString($this->name) . '], '
|
|
29
|
+
. Expression\ArrayNode::fromArguments($this->args)->print($context) . ')';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class StaticCallableNode extends Expression\StaticCallableNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(Expression\StaticCallableNode $from)
|
|
19
|
+
{
|
|
20
|
+
parent::__construct($from->class, $from->name, $from->position);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public function print(PrintContext $context): string
|
|
25
|
+
{
|
|
26
|
+
return '$this->global->sandbox->closure(['
|
|
27
|
+
. $context->memberAsString($this->class) . ', '
|
|
28
|
+
. $context->memberAsString($this->name) . '])';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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\Sandbox\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class StaticPropertyFetchNode extends Expression\StaticPropertyFetchNode
|
|
17
|
+
{
|
|
18
|
+
public function __construct(Expression\StaticPropertyFetchNode $from)
|
|
19
|
+
{
|
|
20
|
+
parent::__construct($from->class, $from->name, $from->position);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public function print(PrintContext $context): string
|
|
25
|
+
{
|
|
26
|
+
return '$this->global->sandbox->prop('
|
|
27
|
+
. $context->memberAsString($this->class) . ', '
|
|
28
|
+
. $context->memberAsString($this->name) . ')'
|
|
29
|
+
. '::$'
|
|
30
|
+
. $context->objectProperty($this->name);
|
|
31
|
+
}
|
|
32
|
+
}
|