mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
增加template.auto_rule 配置参数 设置默认模板渲染的转换处理规则 1 为小写+下划线 其它为 完全转换小写
This commit is contained in:
@@ -116,6 +116,8 @@ return [
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
'template' => [
|
'template' => [
|
||||||
|
// 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写
|
||||||
|
'auto_rule' => 1,
|
||||||
// 模板引擎类型 支持 php think 支持扩展
|
// 模板引擎类型 支持 php think 支持扩展
|
||||||
'type' => 'Think',
|
'type' => 'Think',
|
||||||
// 视图基础目录,配置目录为所有模块的视图起始目录
|
// 视图基础目录,配置目录为所有模块的视图起始目录
|
||||||
|
|||||||
@@ -443,9 +443,6 @@ if (!function_exists('view')) {
|
|||||||
*/
|
*/
|
||||||
function view($template = '', $vars = [], $replace = [], $code = 200)
|
function view($template = '', $vars = [], $replace = [], $code = 200)
|
||||||
{
|
{
|
||||||
if ('' === $template) {
|
|
||||||
$template = Loader::parseName(request()->action(true));
|
|
||||||
}
|
|
||||||
return Response::create($template, 'view', $code)->replace($replace)->assign($vars);
|
return Response::create($template, 'view', $code)->replace($replace)->assign($vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,10 +117,6 @@ class Controller
|
|||||||
*/
|
*/
|
||||||
protected function fetch($template = '', $vars = [], $replace = [], $config = [])
|
protected function fetch($template = '', $vars = [], $replace = [], $config = [])
|
||||||
{
|
{
|
||||||
if ('' === $template) {
|
|
||||||
$template = Loader::parseName($this->request->action(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->view->fetch($template, $vars, $replace, $config);
|
return $this->view->fetch($template, $vars, $replace, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class Php
|
|||||||
if ($controller) {
|
if ($controller) {
|
||||||
if ('' == $template) {
|
if ('' == $template) {
|
||||||
// 如果模板文件名为空 按照默认规则定位
|
// 如果模板文件名为空 按照默认规则定位
|
||||||
$template = str_replace('.', DS, $controller) . $depr . $request->action();
|
$template = str_replace('.', DS, $controller) . $depr . (1 == $this->config['auto_rule'] ? Loader::parseName($request->action(true)) : $request->action());
|
||||||
} elseif (false === strpos($template, $depr)) {
|
} elseif (false === strpos($template, $depr)) {
|
||||||
$template = str_replace('.', DS, $controller) . $depr . $template;
|
$template = str_replace('.', DS, $controller) . $depr . $template;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class Think
|
|||||||
if ($controller) {
|
if ($controller) {
|
||||||
if ('' == $template) {
|
if ('' == $template) {
|
||||||
// 如果模板文件名为空 按照默认规则定位
|
// 如果模板文件名为空 按照默认规则定位
|
||||||
$template = str_replace('.', DS, $controller) . $depr . $request->action();
|
$template = str_replace('.', DS, $controller) . $depr . (1 == $this->config['auto_rule'] ? Loader::parseName($request->action(true)) : $request->action());
|
||||||
} elseif (false === strpos($template, $depr)) {
|
} elseif (false === strpos($template, $depr)) {
|
||||||
$template = str_replace('.', DS, $controller) . $depr . $template;
|
$template = str_replace('.', DS, $controller) . $depr . $template;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user