@@ -33,7 +33,6 @@ public function getConfigSchema(): Nette\Schema\Schema
3333 {
3434 return Expect::structure ([
3535 'debugger ' => Expect::anyOf (true , false , 'all ' ),
36- 'macros ' => Expect::arrayOf ('string ' ),
3736 'extensions ' => Expect::arrayOf ('string|Nette\DI\Definitions\Statement ' ),
3837 'templateClass ' => Expect::string (),
3938 'strictTypes ' => Expect::bool (false ),
@@ -52,36 +51,26 @@ public function loadConfiguration(): void
5251 $ config = $ this ->config ;
5352 $ builder = $ this ->getContainerBuilder ();
5453
55- $ latteFactory = $ builder ->addFactoryDefinition ($ this ->prefix ('latteFactory ' ))
54+ $ builder ->addFactoryDefinition ($ this ->prefix ('latteFactory ' ))
5655 ->setImplement (ApplicationLatte \LatteFactory::class)
5756 ->getResultDefinition ()
5857 ->setFactory (Latte \Engine::class)
5958 ->addSetup ('setTempDirectory ' , [$ this ->tempDir ])
6059 ->addSetup ('setAutoRefresh ' , [$ this ->debugMode ])
61- ->addSetup ('setStrictTypes ' , [$ config ->strictTypes ]);
62-
63- if (version_compare (Latte \Engine::VERSION , '3 ' , '< ' )) {
64- foreach ($ config ->macros as $ macro ) {
65- $ this ->addMacro ($ macro );
66- }
67- } else {
68- $ latteFactory ->addSetup ('setStrictParsing ' , [$ config ->strictParsing ])
69- ->addSetup ('enablePhpLinter ' , [$ config ->phpLinter ]);
70-
71- $ builder ->getDefinition ($ this ->prefix ('latteFactory ' ))
72- ->getResultDefinition ()
60+ ->addSetup ('setStrictTypes ' , [$ config ->strictTypes ])
61+ ->addSetup ('setStrictParsing ' , [$ config ->strictParsing ])
62+ ->addSetup ('enablePhpLinter ' , [$ config ->phpLinter ])
7363 ->addSetup ('? ' , [$ builder ::literal ('func_num_args() && $service->addExtension(new Nette\Bridges\ApplicationLatte\UIExtension(func_get_arg(0))) ' )]);
7464
75- if ($ cache = $ builder ->getByType (Nette \Caching \Storage::class)) {
76- $ this ->addExtension (new Statement (Nette \Bridges \CacheLatte \CacheExtension::class, [$ builder ->getDefinition ($ cache )]));
77- }
78- if (class_exists (Nette \Bridges \FormsLatte \FormsExtension::class)) {
79- $ this ->addExtension (new Statement (Nette \Bridges \FormsLatte \FormsExtension::class));
80- }
65+ if ($ cache = $ builder ->getByType (Nette \Caching \Storage::class)) {
66+ $ this ->addExtension (new Statement (Nette \Bridges \CacheLatte \CacheExtension::class, [$ builder ->getDefinition ($ cache )]));
67+ }
68+ if (class_exists (Nette \Bridges \FormsLatte \FormsExtension::class)) {
69+ $ this ->addExtension (new Statement (Nette \Bridges \FormsLatte \FormsExtension::class));
70+ }
8171
82- foreach ($ config ->extensions as $ extension ) {
83- $ this ->addExtension ($ extension );
84- }
72+ foreach ($ config ->extensions as $ extension ) {
73+ $ this ->addExtension ($ extension );
8574 }
8675
8776 $ builder ->addDefinition ($ this ->prefix ('templateFactory ' ))
@@ -124,40 +113,12 @@ public static function initLattePanel(
124113 $ control = $ template ->getLatte ()->getProviders ()['uiControl ' ] ?? null ;
125114 if ($ all || $ control instanceof Nette \Application \UI \Presenter) {
126115 $ name = $ all && $ control ? (new \ReflectionObject ($ control ))->getShortName () : '' ;
127- if (version_compare (Latte \Engine::VERSION , '3 ' , '< ' )) {
128- $ bar ->addPanel (new Latte \Bridges \Tracy \LattePanel ($ template ->getLatte (), $ name ));
129- } else {
130- $ template ->getLatte ()->addExtension (new Latte \Bridges \Tracy \TracyExtension ($ name ));
131- }
116+ $ template ->getLatte ()->addExtension (new Latte \Bridges \Tracy \TracyExtension ($ name ));
132117 }
133118 };
134119 }
135120
136121
137- public function addMacro (string $ macro ): void
138- {
139- $ builder = $ this ->getContainerBuilder ();
140- $ definition = $ builder ->getDefinition ($ this ->prefix ('latteFactory ' ))->getResultDefinition ();
141-
142- if (($ macro [0 ] ?? null ) === '@ ' ) {
143- if (str_contains ($ macro , ':: ' )) {
144- [$ macro , $ method ] = explode (':: ' , $ macro );
145- } else {
146- $ method = 'install ' ;
147- }
148-
149- $ definition ->addSetup ('?->onCompile[] = function ($engine) { ?-> ' . $ method . '($engine->getCompiler()); } ' , ['@self ' , $ macro ]);
150-
151- } else {
152- if (!str_contains ($ macro , ':: ' ) && class_exists ($ macro )) {
153- $ macro .= '::install ' ;
154- }
155-
156- $ definition ->addSetup ('?->onCompile[] = function ($engine) { ' . $ macro . '($engine->getCompiler()); } ' , ['@self ' ]);
157- }
158- }
159-
160-
161122 public function addExtension (Statement |string $ extension ): void
162123 {
163124 $ extension = is_string ($ extension )
0 commit comments