Skip to content

Commit eefce56

Browse files
committed
Release v1.0.8
1 parent adc5e50 commit eefce56

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/AssetCompiler.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,22 @@ private function processAssetDirectives(string $content): string
197197
// Process @echo directive first (before other directives)
198198
$content = $this->processEchoInAsset($content, $this->data);
199199

200+
// Process @assetDir directive (copy directory, remove comment)
201+
// Supports both HTML (<!--...-->) and CSS/JS (/* ... */) comment styles
202+
$content = preg_replace_callback(
203+
'/(?:<!--|\/\*)\s*@assetDir\((.*?)\)\s*(?:-->|\*\/)/',
204+
function($matches) use ($assetManager) {
205+
$path = trim($matches[1]); // Trim whitespace from path
206+
$assetManager->copyAsset($path);
207+
return ''; // Remove the directive from output
208+
},
209+
$content
210+
);
211+
200212
// Process @asset directive using preg_replace_callback for safe replacement
213+
// Supports both HTML (<!--...-->) and CSS/JS (/* ... */) comment styles
201214
$content = preg_replace_callback(
202-
'/<!--@asset\((.*?)\)-->/',
215+
'/(?:<!--|\/\*)\s*@asset\((.*?)\)\s*(?:-->|\*\/)/',
203216
function($matches) use ($assetManager) {
204217
$path = trim($matches[1]); // Trim whitespace from path
205218
return $assetManager->copyAsset($path);
@@ -208,8 +221,9 @@ function($matches) use ($assetManager) {
208221
);
209222

210223
// Process @base64 directive using preg_replace_callback for safe replacement
224+
// Supports both HTML (<!--...-->) and CSS/JS (/* ... */) comment styles
211225
$content = preg_replace_callback(
212-
'/<!--@base64\((.*?)\)-->/',
226+
'/(?:<!--|\/\*)\s*@base64\((.*?)\)\s*(?:-->|\*\/)/',
213227
function($matches) {
214228
$path = trim($matches[1]); // path (trim whitespace)
215229
$realPath = $this->skinPath . DIRECTORY_SEPARATOR . $path;

0 commit comments

Comments
 (0)