Template类改进layout方法

This commit is contained in:
thinkphp
2016-05-06 21:45:13 +08:00
parent 896b568533
commit 5bcc13a273
2 changed files with 7 additions and 1 deletions

View File

@@ -229,9 +229,10 @@ class Template
* 设置布局 * 设置布局
* @access public * @access public
* @param mixed $name 布局模板名称 false 则关闭布局 * @param mixed $name 布局模板名称 false 则关闭布局
* @param string $replace 布局模板内容替换标识
* @return object * @return object
*/ */
public function layout($name) public function layout($name, $replace = '')
{ {
if (false === $name) { if (false === $name) {
// 关闭布局 // 关闭布局
@@ -243,6 +244,9 @@ class Template
if (is_string($name)) { if (is_string($name)) {
$this->config['layout_name'] = $name; $this->config['layout_name'] = $name;
} }
if (!empty($replace)) {
$this->config['layout_item'] = $replace;
}
} }
return $this; return $this;
} }

View File

@@ -26,6 +26,8 @@ class Think
'view_suffix' => '.html', 'view_suffix' => '.html',
// 模板文件名分隔符 // 模板文件名分隔符
'view_depr' => DS, 'view_depr' => DS,
// 是否开启模板编译缓存,设为false则每次都会重新编译
'tpl_cache' => true,
]; ];
public function __construct($config = []) public function __construct($config = [])