mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
b22c076fc2eee4ba641b7ec20d3f3023da290ef0
This PR was merged into the master branch.
Commits
-------
1918ede added the ability to use any PHP callable to define filters, functions, and tests
Discussion
----------
added the ability to use any PHP callable to define filters, functions, and tests
Everything is in the title.
---------------------------------------------------------------------------
by Tobion at 2012-11-18T13:25:51Z
Are filters etc. slower when defined as closures (instead of function definitions)?
---------------------------------------------------------------------------
by fabpot at 2012-11-18T13:30:47Z
@Tobion No, it does not matter how they are defined. Speed will be the same. A function is probably slightly faster as we can optimize the compiled template more than when it is an anonymous function where we need to use `call_user_func`.
---------------------------------------------------------------------------
by Tobion at 2012-11-18T13:40:17Z
This slight difference is what I questioned. On top of that, PHP can also not precompile those `call_user_func` I guess (e.g. when using APC). But it's probably not a big deal.
Since you have many examples in the doc with closures, I hope that it does not become the standard way for people to define custom functions.
…
…
…
Twig, the flexible, fast, and secure template language for PHP
Twig is a template language for PHP, released under the new BSD license (code and documentation).
Twig uses a syntax similar to the Django and Jinja template languages which inspired the Twig runtime environment.
More Information
Read the documentation for more information.
Description
Languages
PHP
99.9%
