2017 © Pedro Peláez
 

library twig-hashed-file-extension

Include file containing content hash in twig templates

image

agallou/twig-hashed-file-extension

Include file containing content hash in twig templates

  • Sunday, March 13, 2016
  • by agallou
  • Repository
  • 1 Watchers
  • 0 Stars
  • 174 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 12 % Grown

The README.md

twig-hashed-file-extension

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)

Usage

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)

The Versions

13/03 2016

dev-master

9999999-dev

Include file containing content hash in twig templates

  Sources   Download

MIT

The Requires

 

twig assets hash

13/03 2016

0.1.0

0.1.0.0

Include file containing content hash in twig templates

  Sources   Download

MIT

The Requires

 

twig assets hash