mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Add support for fragment in template v2
This commit is contained in:
parent
a6afa3a61d
commit
82b9107ca0
5 changed files with 71 additions and 2 deletions
|
|
@ -28,14 +28,16 @@
|
|||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php $__tmp_RANDOM_LOOP_ID = Context::get('bar') ?? []; if($__tmp_RANDOM_LOOP_ID): $__loop_RANDOM_LOOP_ID = $this->_v2_initLoopVar("RANDOM_LOOP_ID", $__tmp_RANDOM_LOOP_ID); foreach ($__tmp_RANDOM_LOOP_ID as $__Context->k => $__Context->val): ?>
|
||||
<?php ob_start(); $__last_fragment_name = 'rhymix'; ?>
|
||||
<?php $__tmp_64b3371f38fea1 = Context::get('bar') ?? []; if($__tmp_64b3371f38fea1): $__loop_64b3371f38fea1 = $this->_v2_initLoopVar("64b3371f38fea1", $__tmp_64b3371f38fea1); foreach ($__tmp_64b3371f38fea1 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" />
|
||||
<span <?php if ($__Context->k >= 2): ?>class="<?php echo htmlspecialchars($__Context->val ?? '', \ENT_QUOTES, 'UTF-8', false); ?>"<?php endif; ?>></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php $this->_v2_incrLoopVar($__loop_RANDOM_LOOP_ID); endforeach; $this->_v2_removeLoopVar($__loop_RANDOM_LOOP_ID); unset($__loop_RANDOM_LOOP_ID); else: ?><div>Nothing here...</div><?php endif; ?>
|
||||
<?php $this->_v2_incrLoopVar($__loop_64b3371f38fea1); endforeach; $this->_v2_removeLoopVar($__loop_64b3371f38fea1); unset($__loop_64b3371f38fea1); else: ?><div>Nothing here...</div><?php endif; ?>
|
||||
<?php $this->_fragments[$__last_fragment_name] = ob_get_flush(); ?>
|
||||
|
||||
<?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'); ?>
|
||||
|
|
|
|||
21
tests/_data/template/v2example.fragment.html
Normal file
21
tests/_data/template/v2example.fragment.html
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
<div>
|
||||
<img src="/rhymix/tests/_data/template/bar/rhymix.svg" alt="unit tests are cool" />
|
||||
<span ></span>
|
||||
</div>
|
||||
<div>
|
||||
<img src="/rhymix/tests/_data/template/bar/rhymix.svg" alt="unit tests are cool" />
|
||||
<span ></span>
|
||||
</div>
|
||||
<div>
|
||||
<img src="/rhymix/tests/_data/template/bar/rhymix.svg" alt="unit tests are cool" />
|
||||
<span class="is"></span>
|
||||
</div>
|
||||
<div>
|
||||
<img src="/rhymix/tests/_data/template/bar/rhymix.svg" alt="unit tests are cool" />
|
||||
<span class="da"></span>
|
||||
</div>
|
||||
<div>
|
||||
<img src="/rhymix/tests/_data/template/bar/rhymix.svg" alt="unit tests are cool" />
|
||||
<span class="BEST!"></span>
|
||||
</div>
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
@end
|
||||
</div>
|
||||
|
||||
@fragment('rhymix')
|
||||
@forelse (Context::get('bar') as $k => $val)
|
||||
<div>
|
||||
@empty ($nosuchvar)
|
||||
|
|
@ -36,6 +37,7 @@
|
|||
@endempty
|
||||
</div>
|
||||
@empty<div>Nothing here...</div>@end
|
||||
@endfragment
|
||||
|
||||
@each('incl/eachtest', $bar, 'var')
|
||||
@each('incl/eachtest', [], 'anything', 'incl/empty')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue