library twig-static
A filter that takes a static file path and returns a URL versioned with the file hash
fffunction/twig-static
A filter that takes a static file path and returns a URL versioned with the file hash
- Monday, July 10, 2017
- by danreeves
- Repository
- 4 Watchers
- 1 Stars
- 17 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 13 % Grown
twig-static
, (*1)
composer require fffunction/twig-static
Usage
Add the filter to Twig:, (*2)
$twig->addFilter('static', new Twig_Filter_Function(
create_static_filter('path/to/assets/', '/url/to/prepend/')
));
Then pass paths to the filter in your templates:, (*3)
{{ 'js/app.bundle.js' | static }}
{# /url/to/prepend/js/app.bundle.js?v=1a2b3c4 #}
API
create_static_filter(sting $asset_root, string $asset_url): function
- $asset_root
: a relative path from the app root to the assets root dir
- $asset_url
: a path to prepend to the returned url, (*4)
dev-master
9999999-dev
A filter that takes a static file path and returns a URL versioned with the file hash
Sources
Download
MIT
The Development Requires
by
Dan Reeves
1.0.0
1.0.0.0
A filter that takes a static file path and returns a URL versioned with the file hash
Sources
Download
MIT
The Development Requires
by
Dan Reeves