mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 02:52:49 +08:00
feat: 增加var标签
This commit is contained in:
@@ -16,6 +16,7 @@ namespace think\view\driver;
|
||||
use app\common\tools\PathTools;
|
||||
use think\App;
|
||||
use think\facade\Env;
|
||||
use think\helper\Arr;
|
||||
use think\helper\Str;
|
||||
use think\Template;
|
||||
use think\template\exception\TemplateNotFoundException;
|
||||
@@ -39,6 +40,8 @@ class Think
|
||||
'tpl_cache' => true,
|
||||
];
|
||||
|
||||
public $data = [];
|
||||
|
||||
public function __construct(private App $app, array $config = [])
|
||||
{
|
||||
$this->config = array_merge($this->config, (array) $config);
|
||||
@@ -78,6 +81,13 @@ class Think
|
||||
|
||||
return 'app(\'request\')->' . $method . '(' . $params . ')';
|
||||
});
|
||||
|
||||
|
||||
$this->template->extend('$View', function (array $vars) {
|
||||
$params = implode('.', $vars);
|
||||
|
||||
return "'" . Arr::get($this->data, $params, '') . "'";
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,6 +122,7 @@ class Think
|
||||
if (!is_file($template)) {
|
||||
throw new TemplateNotFoundException('template not exists:' . $template, $template);
|
||||
}
|
||||
$this->data = array_merge($this->data, $data);
|
||||
|
||||
return $this->template->fetch($template, $data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user