From 2fd89879d7ad072b9572d81766fad9739b89681d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 31 Mar 2020 23:40:01 +0200 Subject: [PATCH] Template: passes the template to the latte instead of just parameters. Automatically will register methods as latte custom functions --- composer.json | 2 +- src/Bridges/ApplicationLatte/Template.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 8913ee003..e3b06f54f 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "conflict": { "nette/di": "<3.0-stable", "nette/forms": "<3.0", - "latte/latte": "<2.6", + "latte/latte": "<2.7.1", "tracy/tracy": "<2.5" }, "autoload": { diff --git a/src/Bridges/ApplicationLatte/Template.php b/src/Bridges/ApplicationLatte/Template.php index cd8c1bcfd..57b8ae62c 100644 --- a/src/Bridges/ApplicationLatte/Template.php +++ b/src/Bridges/ApplicationLatte/Template.php @@ -42,7 +42,8 @@ final public function getLatte(): Latte\Engine */ public function render(string $file = null, array $params = []): void { - $this->latte->render($file ?: $this->file, $params + $this->getParameters()); + Nette\Utils\Arrays::toObject($params, $this); + $this->latte->render($file ?: $this->file, $this); } @@ -51,7 +52,8 @@ public function render(string $file = null, array $params = []): void */ public function renderToString(string $file = null, array $params = []): string { - return $this->latte->renderToString($file ?: $this->file, $params + $this->getParameters()); + Nette\Utils\Arrays::toObject($params, $this); + return $this->latte->renderToString($file ?: $this->file, $this); }