mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 20:44:28 +09:00
Support legacy "cond" attribute in <include>
This commit is contained in:
parent
6893e08553
commit
0a2af3a1e7
1 changed files with 6 additions and 4 deletions
|
|
@ -307,7 +307,7 @@ class TemplateParser_v2
|
||||||
protected function _convertIncludes(string $content): string
|
protected function _convertIncludes(string $content): string
|
||||||
{
|
{
|
||||||
// Convert XE-style include directives.
|
// Convert XE-style include directives.
|
||||||
$regexp = '#^[\x09\x20]*(<include(?:\s+(?:target|src|if|when|unless|vars)="(?:[^"]+)")+\s*/?>)[\x09\x20]*$#m';
|
$regexp = '#^[\x09\x20]*(<include(?:\s+(?:target|src|if|when|cond|unless|vars)="(?:[^"]+)")+\s*/?>)[\x09\x20]*$#m';
|
||||||
$content = preg_replace_callback($regexp, function($match) {
|
$content = preg_replace_callback($regexp, function($match) {
|
||||||
$attrs = self::_getTagAttributes($match[1]);
|
$attrs = self::_getTagAttributes($match[1]);
|
||||||
$path = $attrs['src'] ?? ($attrs['target'] ?? null);
|
$path = $attrs['src'] ?? ($attrs['target'] ?? null);
|
||||||
|
|
@ -315,13 +315,15 @@ class TemplateParser_v2
|
||||||
$tpl = '<?php $__tpl = new \Rhymix\Framework\Template($this->relative_dirname, "' . $path . '", "' . ($this->template->extension ?: 'auto') . '"); ';
|
$tpl = '<?php $__tpl = new \Rhymix\Framework\Template($this->relative_dirname, "' . $path . '", "' . ($this->template->extension ?: 'auto') . '"); ';
|
||||||
$tpl .= !empty($attrs['vars']) ? ' $__tpl->setVars(' . $attrs['vars'] . '); ' : '';
|
$tpl .= !empty($attrs['vars']) ? ' $__tpl->setVars(' . $attrs['vars'] . '); ' : '';
|
||||||
$tpl .= 'echo $__tpl->compile(); ?>';
|
$tpl .= 'echo $__tpl->compile(); ?>';
|
||||||
if (!empty($attrs['if']) || !empty($attrs['when']))
|
if (!empty($attrs['if']) || !empty($attrs['when']) || !empty($attrs['cond']))
|
||||||
{
|
{
|
||||||
$tpl = '<?php if(!empty(' . ($attrs['if'] ?? $attrs['when']) . ')): ?>' . $tpl . '<?php endif; ?>';
|
$condition = $attrs['if'] ?? ($attrs['when'] ?? $attrs['cond']);
|
||||||
|
$tpl = '<?php if(!empty(' . $condition . ')): ?>' . $tpl . '<?php endif; ?>';
|
||||||
}
|
}
|
||||||
if (!empty($attrs['unless']))
|
if (!empty($attrs['unless']))
|
||||||
{
|
{
|
||||||
$tpl = '<?php if(empty(' . $attrs['unless'] . ')): ?>' . $tpl . '<?php endif; ?>';
|
$condition = $attrs['unless'];
|
||||||
|
$tpl = '<?php if(empty(' . $condition . ')): ?>' . $tpl . '<?php endif; ?>';
|
||||||
}
|
}
|
||||||
return self::_escapeVars($tpl);
|
return self::_escapeVars($tpl);
|
||||||
}, $content);
|
}, $content);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue