Also support $foo->$bar syntax in cond="" and loop="" syntax

This commit is contained in:
Kijin Sung 2022-10-31 01:40:40 +09:00
parent 2a026a6c86
commit 606989c451
2 changed files with 39 additions and 4 deletions

View file

@ -324,6 +324,14 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test
array(
'<!--@if($foo->$bar)--><div></div><!--@endif-->',
"\n" . 'if($__Context->foo->{$__Context->bar}){ ?><div></div><?php } ?>'
),
array(
'<aside cond="$foo->$bar"><img src="" /></aside>',
"\n" . 'if($__Context->foo->{$__Context->bar}){ ?><aside><img src="" /></aside><?php } ?>'
),
array(
'<ul loop="$foo->$bar => $key, $val" class="test"|cond="$foo->$key"><li>{$val}</li></ul>',
"\n" . '$__loop_tmp=$__Context->foo->{$__Context->bar};if($__loop_tmp)foreach($__loop_tmp as $__Context->key=>$__Context->val){ ?><ul<?php if($__Context->foo->{$__Context->key}){ ?> class="test"<?php } ?>><li><?php echo $__Context->val ?></li></ul><?php } ?>'
),
// Rhymix autoescape
array(