dev-master
9999999-devInclude file containing content hash in twig templates
MIT
The Requires
twig assets hash
0.1.0
0.1.0.0Include file containing content hash in twig templates
MIT
The Requires
twig assets hash
Include file containing content hash in twig templates
The grunt-hash grunt plugin allows you to rename files according to their content., (*1)
The robo-hash task allows you to to the same in PHP., (*2)
For example a file named main.css
will be renamed to main.54e79f6f.css
., (*3)
So the file is not easy to include in a Twig template (its name will change at every content change)., (*4)
This plugin adds a twig function called hashed_file
., (*5)
You can call it like this :, (*6)
$twig->addExtension(new \Agallou\TwigHashedFileExtension\Extension(__DIR__ . '/web/assets/', null));
<link rel="stylesheet" href="{{ hashed_file('css/main.css') }}" />
It will look for files called main*.css
in the web/assets/css
directory and serve it as /assets/main.54e79f6f.css
., (*7)
If no file is found or more than one file is found an exception will be thrown., (*8)
Include file containing content hash in twig templates
MIT
twig assets hash
Include file containing content hash in twig templates
MIT
twig assets hash