Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ private function parseInclude(&$content)
unset($array['file']);

// 分析模板文件名并读取内容
$parseStr = $this->parseTemplateName($file);
$parseStr = $this->parseTemplateName($file, $this->config('view_path'));

foreach ($array as $k => $v) {
// 以$开头字符串转换成模板变量
Expand Down Expand Up @@ -1116,12 +1116,13 @@ public function parseThinkVar($vars)
}

/**
* 分析加载的模板文件并读取内容 支持多个模板文件读取
* * 分析加载的模板文件并读取内容 支持多个模板文件读取
* @access private
* @param string $templateName 模板文件名
* @param string $templateName 模板文件名
* @param string $prefixPath 追加路径前缀
* @return string
*/
private function parseTemplateName($templateName)
private function parseTemplateName($templateName, $prefixPath = null)
{
$array = explode(',', $templateName);
$parseStr = '';
Expand All @@ -1131,6 +1132,11 @@ private function parseTemplateName($templateName)
continue;
}

/** 追加路径前缀 */
if (!empty($prefixPath)) {
$templateName = $prefixPath. $templateName;
}

if (0 === strpos($templateName, '$')) {
//支持加载变量文件名
$templateName = $this->get(substr($templateName, 1));
Expand Down