mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
Making docs more explict as to what kind of object can be
used with Twig_Function_Method. Fixes #308
This commit is contained in:
@@ -264,6 +264,11 @@ Adding a function is similar to adding a filter. This can be done by calling the
|
|||||||
|
|
||||||
$twig = new Twig_Environment($loader);
|
$twig = new Twig_Environment($loader);
|
||||||
$twig->addFunction('functionName', new Twig_Function_Function('someFunction'));
|
$twig->addFunction('functionName', new Twig_Function_Function('someFunction'));
|
||||||
|
|
||||||
|
You can also expose extension methods as functions in your templates::
|
||||||
|
|
||||||
|
// $this is an object that implements instance of Twig_ExtensionInterface.
|
||||||
|
$twig = new Twig_Environment($loader);
|
||||||
$twig->addFunction('otherFunction', new Twig_Function_Method($this, 'someMethod'));
|
$twig->addFunction('otherFunction', new Twig_Function_Method($this, 'someMethod'));
|
||||||
|
|
||||||
Functions also support ``needs_environment`` and ``is_safe`` parameters.
|
Functions also support ``needs_environment`` and ``is_safe`` parameters.
|
||||||
|
|||||||
Reference in New Issue
Block a user