From 0a2af3a1e7125b3a0588841f584703ec6a504ff6 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 15 Oct 2023 23:35:06 +0900 Subject: [PATCH] Support legacy "cond" attribute in --- .../framework/parsers/template/TemplateParser_v2.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/framework/parsers/template/TemplateParser_v2.php b/common/framework/parsers/template/TemplateParser_v2.php index c6ab63165..c09742fb3 100644 --- a/common/framework/parsers/template/TemplateParser_v2.php +++ b/common/framework/parsers/template/TemplateParser_v2.php @@ -307,7 +307,7 @@ class TemplateParser_v2 protected function _convertIncludes(string $content): string { // Convert XE-style include directives. - $regexp = '#^[\x09\x20]*()[\x09\x20]*$#m'; + $regexp = '#^[\x09\x20]*()[\x09\x20]*$#m'; $content = preg_replace_callback($regexp, function($match) { $attrs = self::_getTagAttributes($match[1]); $path = $attrs['src'] ?? ($attrs['target'] ?? null); @@ -315,13 +315,15 @@ class TemplateParser_v2 $tpl = 'relative_dirname, "' . $path . '", "' . ($this->template->extension ?: 'auto') . '"); '; $tpl .= !empty($attrs['vars']) ? ' $__tpl->setVars(' . $attrs['vars'] . '); ' : ''; $tpl .= 'echo $__tpl->compile(); ?>'; - if (!empty($attrs['if']) || !empty($attrs['when'])) + if (!empty($attrs['if']) || !empty($attrs['when']) || !empty($attrs['cond'])) { - $tpl = '' . $tpl . ''; + $condition = $attrs['if'] ?? ($attrs['when'] ?? $attrs['cond']); + $tpl = '' . $tpl . ''; } if (!empty($attrs['unless'])) { - $tpl = '' . $tpl . ''; + $condition = $attrs['unless']; + $tpl = '' . $tpl . ''; } return self::_escapeVars($tpl); }, $content);