mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Exclude functions and closures from scope conversion #2617
This commit is contained in:
parent
50dd010e2d
commit
8e5480674d
4 changed files with 88 additions and 0 deletions
|
|
@ -62,6 +62,27 @@
|
|||
<span<?php echo $this->_v2_buildAttribute('style', ['a' => false, 'b' => false]); ?>></span>
|
||||
</div>
|
||||
|
||||
<?php $suffix = &$__Context->suffix;
|
||||
$__Context->employees = [
|
||||
['name' => 'Alice', 'age' => 30],
|
||||
['name' => 'Bob', 'age' => 25],
|
||||
['name' => 'Charlie', 'age' => 35],
|
||||
];
|
||||
$__Context->suffix = '님';
|
||||
$__Context->names = array_map(function($e, $key = 'name') use ($suffix) {
|
||||
return $e[$key] . $suffix;
|
||||
}, $__Context->employees);
|
||||
function convert_names(array $names = array()): array
|
||||
{
|
||||
return array_map(function($name) {
|
||||
return ucfirst($name);
|
||||
}, $names);
|
||||
}
|
||||
?>
|
||||
<div class="employees">
|
||||
<?php echo $this->config->context === 'HTML' ? htmlspecialchars(implode(', ', convert_names($__Context->names)), \ENT_QUOTES, 'UTF-8', false) : $this->_v2_escape(implode(', ', convert_names($__Context->names))); ?> welcome!
|
||||
</div>
|
||||
|
||||
<script type="text/javascript"<?php $this->config->context = 'JS'; ?>>
|
||||
const foo = '<?php echo $this->config->context === 'HTML' ? htmlspecialchars($__Context->foo ?? '', \ENT_QUOTES, 'UTF-8', false) : $this->_v2_escape($__Context->foo ?? ''); ?>';
|
||||
const bar = <?php echo $this->config->context === 'JS' ? json_encode($__Context->bar, self::$_json_options2) : htmlspecialchars(json_encode($__Context->bar, self::$_json_options), \ENT_QUOTES, 'UTF-8', false); ?>;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,10 @@
|
|||
<span></span>
|
||||
</div>
|
||||
|
||||
<div class="employees">
|
||||
Alice님, Bob님, Charlie님 welcome!
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
const foo = 'FOOFOO\u003C\u0022FOO\u0022\u003EBAR';
|
||||
const bar = ["Rhy","miX","is","da","BEST!"];
|
||||
|
|
|
|||
|
|
@ -62,6 +62,27 @@
|
|||
<span @style(['a' => false, 'b' => false])></span>
|
||||
</div>
|
||||
|
||||
@php
|
||||
$employees = [
|
||||
['name' => 'Alice', 'age' => 30],
|
||||
['name' => 'Bob', 'age' => 25],
|
||||
['name' => 'Charlie', 'age' => 35],
|
||||
];
|
||||
$suffix = '님';
|
||||
$names = array_map(function($e, $key = 'name') use ($suffix) {
|
||||
return $e[$key] . $suffix;
|
||||
}, $employees);
|
||||
function convert_names(array $names = array()): array
|
||||
{
|
||||
return array_map(function($name) {
|
||||
return ucfirst($name);
|
||||
}, $names);
|
||||
}
|
||||
@endphp
|
||||
<div class="employees">
|
||||
{{ implode(', ', convert_names($names)) }} welcome!
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
const foo = '{{ $foo }}';
|
||||
const bar = @json($bar);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue