Skip to content

Call (almost) any PHP function from your Twig templates.

Notifications You must be signed in to change notification settings

Pongtan/twig-php-function

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

symfony upgrade fixertwig gettext extractorwisdomcentipedepermissions handlerextraloadgravatarlocurrocountry listtransliterator

Twig PHP Function Build Status

Call (almost) any PHP function from your Twig templates.

Usage

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.

Extend

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.

About

Call (almost) any PHP function from your Twig templates.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%