From dceb42a327ce1e57f71db18f08030700f9fc08a1 Mon Sep 17 00:00:00 2001 From: fabien Date: Tue, 22 Dec 2009 14:48:42 +0000 Subject: [PATCH] tweaked a bit the documentation git-svn-id: http://svn.twig-project.org/trunk@204 93ef8e89-cb99-4229-a87c-7fa0fa45744b --- doc/04-Extending-Twig.markdown | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/doc/04-Extending-Twig.markdown b/doc/04-Extending-Twig.markdown index 2093b9f..22df4b1 100644 --- a/doc/04-Extending-Twig.markdown +++ b/doc/04-Extending-Twig.markdown @@ -58,12 +58,21 @@ inherit from the `Twig_Extension` class, which provides empty implementations of all the above methods to keep your extension clean. The `getName()` method must always be implemented to return a unique -identifier for the extension. +identifier for the extension. Here is the most basic extension you can create: + + [php] + class Project_Twig_Extension extends Twig_Extension + { + public function getName() + { + return 'project'; + } + } >**TIP** >The bundled extensions are great examples of how extensions work. -Registering a custom extension is like registering any other core extension: +Registering a custom extension is like registering any other extension: [php] $twig->addExtension(new Project_Twig_Extension()); @@ -89,9 +98,10 @@ a string: {# should displays Gjvt #} -A filter is defined as a sub-class of the `Twig_Filter` class. The -`Twig_Filter_Function` class can be used to define a filter implemented as a -function: +A filter is defined as an object of class `Twig_Filter`. + +The `Twig_Filter_Function` class can be used to define a filter implemented as +a function: [php] $filter = new Twig_Filter_Function('str_rot13'); -- 1.7.2.5