3232 *
3333 * @package BladeOne
3434 * @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.
3636 * Don't delete this comment, its part of the license.
3737 * Part of this code is based in the work of Laravel PHP Components.
38- * @version 4.17.1
38+ * @version 4.18
3939 * @link https://github.com/EFTEC/BladeOne
4040 */
4141class BladeOne
4242{
4343 //<editor-fold desc="fields">
44- public const VERSION = '4.17.1 ' ;
44+ public const VERSION = '4.18 ' ;
4545 /** @var int BladeOne reads if the compiled file has changed. If it has changed,then the file is replaced. */
4646 public const MODE_AUTO = 0 ;
4747 /** @var int Then compiled file is always replaced. It's slow and it's useful for development. */
@@ -180,6 +180,7 @@ class BladeOne
180180 protected int $ uidCounter = 0 ;
181181 /** @var string The main url of the system. Don't use raw $_SERVER values unless the value is sanitized */
182182 protected string $ baseUrl = '. ' ;
183+ protected string $ cdnUrl = '. ' ;
183184 /** @var string|null The base domain of the system */
184185 protected ?string $ baseDomain ;
185186 /** @var string|null It stores the current canonical url. */
@@ -190,6 +191,7 @@ class BladeOne
190191 protected string $ relativePath = '' ;
191192 /** @var string[] Dictionary of assets */
192193 protected array $ assetDict = [];
194+ protected array $ assetDictCDN = [];
193195 /** @var bool if true then it removes tabs and unneeded spaces */
194196 protected bool $ optimize = true ;
195197 /** @var bool if false, then the template is not compiled (but executed on memory). */
@@ -881,6 +883,14 @@ public function addAssetDict($name, $url = ''): void
881883 $ this ->assetDict [$ name ] = $ url ;
882884 }
883885 }
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+ }
884894
885895 /**
886896 * Compile the push statements into valid PHP.
@@ -4269,6 +4279,10 @@ protected function compileAsset($expression): string
42694279 {
42704280 return $ this ->phpTagEcho . "(isset( \$this->assetDict[ $ expression]))? \$this->assetDict[ $ expression]: \$this->baseUrl.'/'. $ expression; ?> " ;
42714281 }
4282+ protected function compileAssetCDN ($ expression ): string
4283+ {
4284+ return $ this ->phpTagEcho . "(isset( \$this->assetDictCDN[ $ expression]))? \$this->assetDictCDN[ $ expression]: \$this->cdnUrl.'/'. $ expression; ?> " ;
4285+ }
42724286
42734287 protected function compileJSon ($ expression ): string
42744288 {
0 commit comments