Twig extension for versioning assets.
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require shadesoft/twig-asset-version
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
# app/config/services.yml for Symfony 3 or config/services.yaml for Symfony 4
ShadeSoft\Twig\AssetVersionExtension: ~
# app/config/services.yml
shadesoft.twig.asset_version_extension:
class: ShadeSoft\Twig\AssetVersionExtension
tags:
- { name: twig.extension }
// src/dependencies.php
// ...
$container['view'] = function($c) {
//...
$view->addExtension(new ShadeSoft\Twig\AssetVersionExtension);
//...
}
Add \ShadeSoft\Twig\AssetVersionExtension to your Twig environment's dependencies (or include into one of the frameworks above), then you can use the filter:
{{ 'asset_path'|versionify }}