diff --git a/src/Theme/AssetManager.php b/src/Theme/AssetManager.php
index 2d10cd44e..51a713fcb 100644
--- a/src/Theme/AssetManager.php
+++ b/src/Theme/AssetManager.php
@@ -49,14 +49,18 @@ protected function getMainJs(): string
return $this->mainJs;
}
- public function add(string|array $assets): void
+ public function add(string|array|Closure $assets): void
{
- $this->assets = array_unique(
- array_merge(
- $this->assets,
- is_array($assets) ? $assets : [$assets]
- )
- );
+ if (is_closure($assets)) {
+ $this->lazyAssign($assets);
+ } else {
+ $this->assets = array_unique(
+ array_merge(
+ $this->assets,
+ is_array($assets) ? $assets : [$assets]
+ )
+ );
+ }
}
public function getAssets(): array
@@ -73,8 +77,8 @@ public function js(): string
)
->map(
fn ($asset): string => ""
+ $asset
+ ) . (str_contains((string) $asset, '?') ? '&' : '?') . "v={$this->getVersion()}'>"
)->implode(PHP_EOL);
}
@@ -87,8 +91,8 @@ public function css(): string
)
->map(
fn ($asset): string => "getVersion()}' rel='stylesheet'>"
+ $asset
+ ) . (str_contains((string) $asset, '?') ? '&' : '?') . "v={$this->getVersion()}' rel='stylesheet'>"
)->implode(PHP_EOL);
}