Change desktop and mobile directives to reference static Context method

This commit is contained in:
Kijin Sung 2023-10-21 13:35:24 +09:00
parent fbc5564247
commit 5b47151440
3 changed files with 5 additions and 5 deletions

View file

@ -104,8 +104,8 @@ class TemplateParser_v2
'cannot' => ['if ($this->_v2_checkCapability(2, %s)):', 'endif;'], 'cannot' => ['if ($this->_v2_checkCapability(2, %s)):', 'endif;'],
'canany' => ['if ($this->_v2_checkCapability(3, %s)):', 'endif;'], 'canany' => ['if ($this->_v2_checkCapability(3, %s)):', 'endif;'],
'guest' => ['if (!$this->user->isMember()):', 'endif;'], 'guest' => ['if (!$this->user->isMember()):', 'endif;'],
'desktop' => ['if (!$__Context->m):', 'endif;'], 'desktop' => ["if (!\\Context::get('m')):", 'endif;'],
'mobile' => ['if ($__Context->m):', 'endif;'], 'mobile' => ["if (\\Context::get('m')):", 'endif;'],
'env' => ['if (!empty($_ENV[%s])):', 'endif;'], 'env' => ['if (!empty($_ENV[%s])):', 'endif;'],
'else' => ['else:'], 'else' => ['else:'],
'elseif' => ['elseif (%s):'], 'elseif' => ['elseif (%s):'],

View file

@ -42,7 +42,7 @@
<?php (function($__filename, $__vars, $__varname, $__empty = null) { if (!$__vars): $__vars = []; if ($__empty): $__filename = $__empty; $__vars[] = ''; endif; endif; foreach ($__vars as $__var): echo $this->_v2_include("include", $__filename, [(string)$__varname => $__var]); endforeach; })('incl/eachtest', $__Context->bar, 'var'); ?> <?php (function($__filename, $__vars, $__varname, $__empty = null) { if (!$__vars): $__vars = []; if ($__empty): $__filename = $__empty; $__vars[] = ''; endif; endif; foreach ($__vars as $__var): echo $this->_v2_include("include", $__filename, [(string)$__varname => $__var]); endforeach; })('incl/eachtest', $__Context->bar, 'var'); ?>
<?php (function($__filename, $__vars, $__varname, $__empty = null) { if (!$__vars): $__vars = []; if ($__empty): $__filename = $__empty; $__vars[] = ''; endif; endif; foreach ($__vars as $__var): echo $this->_v2_include("include", $__filename, [(string)$__varname => $__var]); endforeach; })('incl/eachtest', [], 'anything', 'incl/empty'); ?> <?php (function($__filename, $__vars, $__varname, $__empty = null) { if (!$__vars): $__vars = []; if ($__empty): $__filename = $__empty; $__vars[] = ''; endif; endif; foreach ($__vars as $__var): echo $this->_v2_include("include", $__filename, [(string)$__varname => $__var]); endforeach; })('incl/eachtest', [], 'anything', 'incl/empty'); ?>
<?php if (!$__Context->m): ?> <?php if (!\Context::get('m')): ?>
<p>The full class name is <?php echo htmlspecialchars(get_class(new Rhymix\Framework\Push), \ENT_QUOTES, 'UTF-8', true); ?>, <?php echo $this->config->context === 'JS' ? escape_js(Rhymix\Framework\Push::class) : htmlspecialchars(Rhymix\Framework\Push::class, \ENT_QUOTES, 'UTF-8', false); ?> really.</p> <p>The full class name is <?php echo htmlspecialchars(get_class(new Rhymix\Framework\Push), \ENT_QUOTES, 'UTF-8', true); ?>, <?php echo $this->config->context === 'JS' ? escape_js(Rhymix\Framework\Push::class) : htmlspecialchars(Rhymix\Framework\Push::class, \ENT_QUOTES, 'UTF-8', false); ?> really.</p>
<?php endif; ?> <?php endif; ?>

View file

@ -818,10 +818,10 @@ class TemplateParserV2Test extends \Codeception\Test\Unit
'@endmobile', '@endmobile',
]); ]);
$target = implode("\n", [ $target = implode("\n", [
'<?php if (!$__Context->m): ?>', "<?php if (!\\Context::get('m')): ?>",
'<p>4K or GTFO!</p>', '<p>4K or GTFO!</p>',
'<?php endif; ?>', '<?php endif; ?>',
'<?php if ($__Context->m): ?>', "<?php if (\\Context::get('m')): ?>",
'<p>USB C is the way to go~</p>', '<p>USB C is the way to go~</p>',
'<?php endif; ?>', '<?php endif; ?>',
]); ]);