改进Response类 改进view助手函数 增加 think\response\Html 类

This commit is contained in:
thinkphp
2016-05-16 15:16:47 +08:00
parent 199825ec32
commit 30a6bd7e8a
6 changed files with 141 additions and 22 deletions

View File

@@ -95,12 +95,13 @@ class View
* 解析和获取模板内容 用于输出
* @param string $template 模板文件名或者内容
* @param array $vars 模板输出变量
* @param array $replace 替换内容
* @param array $config 模板参数
* @param bool $renderContent 是否渲染内容
* @param bool $renderContent 是否渲染内容
* @return string
* @throws Exception
*/
public function fetch($template = '', $vars = [], $config = [], $renderContent = false)
public function fetch($template = '', $vars = [], $replace = [], $config = [], $renderContent = false)
{
// 模板变量
$vars = array_merge($this->data, $vars);
@@ -118,8 +119,9 @@ class View
// 内容过滤标签
APP_HOOK && Hook::listen('view_filter', $content);
// 允许用户自定义模板的字符串替换
if (!empty($this->replace)) {
$content = strtr($content, $this->replace);
$replace = array_merge($this->replace, $replace);
if (!empty($replace)) {
$content = strtr($content, $replace);
}
return $content;
}
@@ -146,12 +148,13 @@ class View
* @access public
* @param string $content 内容
* @param array $vars 模板输出变量
* @param array $replace 替换内容
* @param array $config 模板参数
* @return mixed
*/
public function display($content, $vars = [], $config = [])
public function display($content, $vars = [], $replace = [], $config = [])
{
return $this->fetch($content, $vars, $config, true);
return $this->fetch($content, $vars, $replace, $config, true);
}
/**