|
2 years ago | |
---|---|---|
.. | ||
examples | 2 years ago | |
spec/Umpirsky/Twig/Extension | 2 years ago | |
src/Umpirsky/Twig/Extension | 2 years ago | |
tests/Umpirsky/Twig/Extension | 2 years ago | |
.gitignore | 2 years ago | |
.travis.yml | 2 years ago | |
README.md | 2 years ago | |
composer.json | 2 years ago | |
composer.lock | 2 years ago |
<a href="https://github.com/umpirsky">
<img src="https://farm2.staticflickr.com/1709/25098526884_ae4d50465f_o_d.png" />
</a>
symfony upgrade fixer • twig gettext extractor • wisdom • centipede • permissions handler • extraload • gravatar • locurro • country list • transliterator
Call (almost) any PHP function from your Twig templates.
After registering PhpFunctionExtension
call PHP functions from your templates like this:
Hi, I am unique: {{ uniqid() }}.
And {{ floor(7.7) }} is floor of 7.7.
You can control allowed PHP functions by adding new ones like this:
$extension = new Umpirsky\Twig\Extension\PhpFunctionExtension();
$extension->allowFunction('hash_hmac');
or restrict what functions are allowed like this:
$extension = new Umpirsky\Twig\Extension\PhpFunctionExtension(['floor', 'ceil']);
If you think that some function should be allowed/not allowed, feel free to raise issue or submit a pull request.