Useful macros for latte assets
- PHP 5.6 or higher
- Nette Framework 2.4 or higher
The best way to install Instante assets is using Composer:
$ composer require instante/assets
Then add new extension to neon configuration
extensions:
assets: Instante\Assets\DI\AssetsExtension
Instead of following code:
<link rel="stylesheet" href="{$basePath}/css/main.min.css">
you should use:
<link rel="stylesheet" href="{hashedAssetVersion 'css/main.min.css'}">
It will automatically generates MD5 hash of current asset to prevent unwanted caching. Hash is regenerated after 1 week or after you manually clear cache.
To simply prepend $basePath url to asset, you can use macro {asset 'path/to/file'}
.