From c178c2818ec3022b7e6302029065b09808e27fcf Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 26 Jun 2011 17:31:56 -0400 Subject: [PATCH] Making docs more explict as to what kind of object can be used with Twig_Function_Method. Fixes #308 --- doc/advanced.rst | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) 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. -- 1.7.2.5