Permalink
Browse files

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
  • Loading branch information...
2 parents 612fa7b + c178c28 commit cdd8351cf58babc767a8fbe0a3f6d05df90373ff @fabpot fabpot committed Jun 27, 2011
Showing with 5 additions and 0 deletions.
  1. +5 −0 doc/advanced.rst
View
@@ -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.

0 comments on commit cdd8351

Please sign in to comment.