mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Add support for Blade-style @each include loop
This commit is contained in:
parent
eba9a4d333
commit
668feea9e9
7 changed files with 56 additions and 4 deletions
1
tests/_data/template/incl/eachtest.html
Normal file
1
tests/_data/template/incl/eachtest.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<div>{$var}</div>
|
||||
1
tests/_data/template/incl/empty.html
Normal file
1
tests/_data/template/incl/empty.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<div>Empty</div>
|
||||
|
|
@ -39,6 +39,9 @@
|
|||
<div>Nothing here...</div>
|
||||
@end
|
||||
|
||||
@each('incl/eachtest', $bar, 'var')
|
||||
@each('incl/eachtest', [], 'anything', 'incl/empty')
|
||||
|
||||
@desktop
|
||||
<p>The full class name is {get_class(new Push)|escape}, {Push::class} really.</p>
|
||||
@enddesktop
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php $__tmp_19148045bac5d8 = Context::get('bar') ?? []; if($__tmp_19148045bac5d8): foreach ($__tmp_19148045bac5d8 as $__Context->k => $__Context->val): ?>
|
||||
<?php $__tmp_042521f3da7d65 = Context::get('bar') ?? []; if($__tmp_042521f3da7d65): foreach ($__tmp_042521f3da7d65 as $__Context->k => $__Context->val): ?>
|
||||
<div>
|
||||
<?php if (empty($__Context->nosuchvar)): ?>
|
||||
<img src="/rhymix/tests/_data/template/bar/rhymix.svg" alt="unit tests are cool" />
|
||||
|
|
@ -39,6 +39,9 @@
|
|||
<div>Nothing here...</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php (function($__dir, $__path, $__vars, $__varname, $__empty = null) { if (!$__vars): $__vars = []; if ($__empty): $__path = $__empty; $__vars[] = ''; endif; endif; foreach ($__vars as $__var): $__tpl = new \Rhymix\Framework\Template($__dir, $__path, "html"); $__tpl->setVars([(string)$__varname => $__var]); echo $__tpl->compile(); endforeach; })($this->relative_dirname, 'incl/eachtest', $__Context->bar, 'var'); ?>
|
||||
<?php (function($__dir, $__path, $__vars, $__varname, $__empty = null) { if (!$__vars): $__vars = []; if ($__empty): $__path = $__empty; $__vars[] = ''; endif; endif; foreach ($__vars as $__var): $__tpl = new \Rhymix\Framework\Template($__dir, $__path, "html"); $__tpl->setVars([(string)$__varname => $__var]); echo $__tpl->compile(); endforeach; })($this->relative_dirname, 'incl/eachtest', [], 'anything', 'incl/empty'); ?>
|
||||
|
||||
<?php if (!$__Context->m): ?>
|
||||
<p>The full class name is <?php echo htmlspecialchars(get_class(new Rhymix\Framework\Push), \ENT_QUOTES, 'UTF-8', true); ?>, <?php echo htmlspecialchars(Rhymix\Framework\Push::class, \ENT_QUOTES, 'UTF-8', false); ?> really.</p>
|
||||
<?php endif; ?>
|
||||
|
|
|
|||
|
|
@ -40,6 +40,13 @@
|
|||
<span class="BEST!"></span>
|
||||
</div>
|
||||
|
||||
<div>Rhy</div>
|
||||
<div>miX</div>
|
||||
<div>is</div>
|
||||
<div>da</div>
|
||||
<div>BEST!</div>
|
||||
<div>Empty</div>
|
||||
|
||||
<p>The full class name is Rhymix\Framework\Push, Rhymix\Framework\Push really.</p>
|
||||
|
||||
<div class="barContainer" data-bar="["Rhy","miX","is","da","BEST!"]"></div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue