merged branch markstory/fix-308 (PR #372)

Commits
-------

c178c28 Making docs more explict as to what kind of object can be used with Twig_Function_Method. Fixes #308

Discussion
----------

Fix for #308

Making docs more explict as to what kind of object can be used with Twig_Function_Method.
Fixes #308
This commit is contained in:
Fabien Potencier
2011-06-27 09:29:21 +02:00
+5
View File
@@ -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->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'));
Functions also support ``needs_environment`` and ``is_safe`` parameters.