Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit cdd8351cf58babc767a8fbe0a3f6d05df90373ff 2 parents 612fa7b + c178c28
@fabpot fabpot authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 doc/advanced.rst
View
5 doc/advanced.rst
@@ -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.
Please sign in to comment.
Something went wrong with that request. Please try again.