siteparts/plates-asset

Generate cache busted web assets URLs in Plates

v1.0.0 2023-11-08 11:40 UTC

This package is auto-updated.

Last update: 2024-03-08 12:20:57 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.