From: Mark Story Date: Sun, 26 Jun 2011 21:31:56 +0000 (-0400) Subject: Making docs more explict as to what kind of object can be X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=c178c2818ec3022b7e6302029065b09808e27fcf;p=web%2Fkonrad%2Ftwig.git Making docs more explict as to what kind of object can be used with Twig_Function_Method. Fixes #308 --- diff --git a/doc/advanced.rst b/doc/advanced.rst index b45b5c9..12f44b9 100644 --- a/doc/advanced.rst +++ b/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.