Template类增加layout方法 模板引擎驱动支持直接调用模板引擎的方法

This commit is contained in:
thinkphp
2016-02-20 18:24:55 +08:00
parent 5217692224
commit b7632a5a52
2 changed files with 56 additions and 40 deletions

View File

@@ -8,7 +8,6 @@
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think\view\driver;
use think\Template;
@@ -16,33 +15,31 @@ use think\Template;
class Think
{
private $template = null;
public function __construct($config = [])
{
$this->template = new Template($config);
}
public function fetch($template, $data = [], $cache = [])
/**
* 渲染模板文件
* @access public
* @param string $template 模板文件或者内容
* @param array $data 模板变量
* @param array $config 模板参数
* @return void
*/
public function fetch($template, $data = [], $config = [])
{
if (is_file($template)) {
$this->template->display($template, $data, $cache);
$this->template->display($template, $data, $config);
} else {
$this->template->fetch($template, $data);
}
}
/**
* 修改模板引擎配置项
* @access public
* @param array|string $config
* @return string|array
*/
public function config($config)
public function __call($method, $params)
{
if(is_array($config)){
$this->template->config($config);
return $this;
}else{
return $this->template->config($config);
}
return call_user_func_array([$this->template, $method], $params);
}
}