Skip to content

Commit 9e594a8

Browse files
committed
fix(view): add missing sprintf placeholder for scoped variables
1 parent a3300e2 commit 9e594a8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/view/src/Elements/ViewComponentElement.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function compile(): string
141141
->prepend(
142142
// Open the current scope
143143
sprintf(
144-
'<?php (function ($attributes, $slots, $scopedVariables %s %s) { extract($scopedVariables, EXTR_SKIP); ?>',
144+
'<?php (function ($attributes, $slots, $scopedVariables %s %s %s) { extract($scopedVariables, EXTR_SKIP); ?>',
145145
$this->dataAttributes->isNotEmpty() ? ', ' . $this->dataAttributes->map(fn (string $_value, string $key) => "\${$key}")->implode(', ') : '',
146146
$this->expressionAttributes->isNotEmpty() ? ', ' . $this->expressionAttributes->map(fn (string $_value, string $key) => "\${$key}")->implode(', ') : '',
147147
$this->scopedVariables->isNotEmpty() ? ', ' . $this->scopedVariables->map(fn (string $name) => "\${$name}")->implode(', ') : '',
@@ -150,7 +150,7 @@ public function compile(): string
150150
->append(
151151
// Close and call the current scope
152152
sprintf(
153-
'<?php })(attributes: %s, slots: %s, scopedVariables: [%s] + ($scopedVariables ?? $this->currentView?->data ?? []) %s %s) ?>',
153+
'<?php })(attributes: %s, slots: %s, scopedVariables: [%s] + ($scopedVariables ?? $this->currentView?->data ?? []) %s %s %s) ?>',
154154
ViewObjectExporter::export($this->viewComponentAttributes),
155155
ViewObjectExporter::export($slots),
156156
$this->scopedVariables->isNotEmpty()
@@ -162,6 +162,9 @@ public function compile(): string
162162
$this->expressionAttributes->isNotEmpty()
163163
? ', ' . $this->expressionAttributes->map(fn (mixed $value, string $key) => "{$key}: " . $value)->implode(', ')
164164
: '',
165+
$this->scopedVariables->isNotEmpty()
166+
? ', ' . $this->scopedVariables->map(fn (string $name) => "{$name}: \${$name}")->implode(', ')
167+
: '',
165168
),
166169
);
167170

0 commit comments

Comments
 (0)