From 086852a0c63bd65d9f1f7d3d41655036369b5d33 Mon Sep 17 00:00:00 2001 From: augushong Date: Thu, 14 Apr 2022 10:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=95=E5=9B=BE=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E6=B3=95=E6=B2=A1=E8=BE=BE=E5=88=B0=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E9=A2=84=E6=9C=9F=E6=95=88=E6=9E=9C=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/think/View.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/think/View.php b/src/think/View.php index 2e7108840f..1a0c5b763b 100644 --- a/src/think/View.php +++ b/src/think/View.php @@ -8,7 +8,7 @@ // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -39,11 +39,18 @@ class View extends Manager * 获取模板引擎 * @access public * @param string $type 模板引擎类型 + * @param bool $return_driver 是否返回引擎驱动 * @return $this */ - public function engine(string $type = null) + public function engine(string $type = null, bool $return_driver = false) { - return $this->driver($type); + $driver = $this->driver($type); + + if ($return_driver) { + return $driver; + } + + return $this; } /** @@ -87,7 +94,7 @@ public function filter(callable $filter = null) public function fetch(string $template = '', array $vars = []): string { return $this->getContent(function () use ($vars, $template) { - $this->engine()->fetch($template, array_merge($this->data, $vars)); + $this->engine(null, true)->fetch($template, array_merge($this->data, $vars)); }); } @@ -101,7 +108,7 @@ public function fetch(string $template = '', array $vars = []): string public function display(string $content, array $vars = []): string { return $this->getContent(function () use ($vars, $content) { - $this->engine()->display($content, array_merge($this->data, $vars)); + $this->engine(null, true)->display($content, array_merge($this->data, $vars)); }); } @@ -187,5 +194,4 @@ public function getDefaultDriver() { return $this->app->config->get('view.type', 'php'); } - }