32
32
*
33
33
* @package BladeOne
34
34
* @author Jorge Patricio Castro Castillo <jcastro arroba eftec dot cl>
35
- * @copyright Copyright (c) 2016-2024 Jorge Patricio Castro Castillo MIT License.
35
+ * @copyright Copyright (c) 2016-2025 Jorge Patricio Castro Castillo MIT License.
36
36
* Don't delete this comment, its part of the license.
37
37
* Part of this code is based in the work of Laravel PHP Components.
38
- * @version 4.17.1
38
+ * @version 4.18
39
39
* @link https://github.com/EFTEC/BladeOne
40
40
*/
41
41
class BladeOne
42
42
{
43
43
//<editor-fold desc="fields">
44
- public const VERSION = '4.17.1 ' ;
44
+ public const VERSION = '4.18 ' ;
45
45
/** @var int BladeOne reads if the compiled file has changed. If it has changed,then the file is replaced. */
46
46
public const MODE_AUTO = 0 ;
47
47
/** @var int Then compiled file is always replaced. It's slow and it's useful for development. */
@@ -180,6 +180,7 @@ class BladeOne
180
180
protected int $ uidCounter = 0 ;
181
181
/** @var string The main url of the system. Don't use raw $_SERVER values unless the value is sanitized */
182
182
protected string $ baseUrl = '. ' ;
183
+ protected string $ cdnUrl = '. ' ;
183
184
/** @var string|null The base domain of the system */
184
185
protected ?string $ baseDomain ;
185
186
/** @var string|null It stores the current canonical url. */
@@ -190,6 +191,7 @@ class BladeOne
190
191
protected string $ relativePath = '' ;
191
192
/** @var string[] Dictionary of assets */
192
193
protected array $ assetDict = [];
194
+ protected array $ assetDictCDN = [];
193
195
/** @var bool if true then it removes tabs and unneeded spaces */
194
196
protected bool $ optimize = true ;
195
197
/** @var bool if false, then the template is not compiled (but executed on memory). */
@@ -881,6 +883,14 @@ public function addAssetDict($name, $url = ''): void
881
883
$ this ->assetDict [$ name ] = $ url ;
882
884
}
883
885
}
886
+ public function addAssetDictCDN ($ name , $ url = '' ): void
887
+ {
888
+ if (\is_array ($ name )) {
889
+ $ this ->assetDictCDN = \array_merge ($ this ->assetDictCDN , $ name );
890
+ } else {
891
+ $ this ->assetDictCDN [$ name ] = $ url ;
892
+ }
893
+ }
884
894
885
895
/**
886
896
* Compile the push statements into valid PHP.
@@ -4269,6 +4279,10 @@ protected function compileAsset($expression): string
4269
4279
{
4270
4280
return $ this ->phpTagEcho . "(isset( \$this->assetDict[ $ expression]))? \$this->assetDict[ $ expression]: \$this->baseUrl.'/'. $ expression; ?> " ;
4271
4281
}
4282
+ protected function compileAssetCDN ($ expression ): string
4283
+ {
4284
+ return $ this ->phpTagEcho . "(isset( \$this->assetDictCDN[ $ expression]))? \$this->assetDictCDN[ $ expression]: \$this->cdnUrl.'/'. $ expression; ?> " ;
4285
+ }
4272
4286
4273
4287
protected function compileJSon ($ expression ): string
4274
4288
{
0 commit comments