From b40030abce3917c11209d73b2e6f2b3b732f9523 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 11 Dec 2015 23:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bview=E7=B1=BB=E7=9A=84fetch?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E5=A2=9E=E5=8A=A0=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/view.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/think/view.php b/library/think/view.php index b4f5ff5c..56c80944 100644 --- a/library/think/view.php +++ b/library/think/view.php @@ -30,6 +30,7 @@ class View 'view_suffix' => '.html', 'view_depr' => '/', 'view_layer' => VIEW_LAYER, + 'parse_str' => [], 'engine_type' => 'think', ]; @@ -148,7 +149,13 @@ class View is_file($template) ? include $template : eval('?>' . $template); } // 获取并清空缓存 - return ob_get_clean(); + $content = ob_get_clean(); + // 允许用户自定义模板的字符串替换 + if (!empty($this->config['parse_str'])) { + $replace = $this->config['parse_str']; + $content = str_replace(array_keys($replace), array_values($replace), $content); + } + return $content; } /**