siteparts / plates-asset
Generate cache busted web assets URLs in Plates
v1.0.0
2023-11-08 11:40 UTC
Requires
- league/plates: ^3.1
- siteparts/asset: ^1.0
Requires (Dev)
- phpstan/phpstan: ^1.10
Suggests
- psr/container: ^1.0 || ^2.0 to use the factory
This package is auto-updated.
Last update: 2024-11-08 13:44:06 UTC
README
Generate cache busted web assets URLs in Plates.
plates-asset uses asset to generate cache busted assets URLs in Plates.
Installation
Via Composer:
$ composer require siteparts/plates-asset
Usage
Setup AssetHelper according to the asset instructions and enable the extension:
use SiteParts\Templating\Plates\Extension\Asset\AssetExtension; // $engine is instance of League\Plates\Engine // $assetHelper is instance of SiteParts\Asset\AssetHelper $engine->loadExtension(new AssetExtension($assetHelper));
Use assetUrl
in your template:
<img src="<?= $this->assetUrl("img/image.png") ?>" alt="...">
For use with a PSR-11 container, you can also use the ConfigProvider
supplied.