Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

模板include参数支持变量和函数传递方式 #2511

Open
wants to merge 2 commits into
base: 5.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions library/think/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ private function parseInclude(&$content)

foreach ($array as $k => $v) {
// 以$开头字符串转换成模板变量
if (0 === strpos($v, '$')) {
$v = $this->get(substr($v, 1));
if (0 === strpos($v, '$') || 0 === strpos($v, ':')) {
$v = '{' . $v . '}';
}

$parseStr = str_replace('[' . $k . ']', $v, $parseStr);
Expand Down Expand Up @@ -1290,6 +1290,7 @@ private function getRegex($tagName)
break;
case 'include':
$name = 'file';
// no break
case 'taglib':
case 'layout':
case 'extend':
Expand Down