mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 20:06:31 +00:00
added some more information about creating a filter with some arguments
git-svn-id: http://svn.twig-project.org/trunk@101 93ef8e89-cb99-4229-a87c-7fa0fa45744b
This commit is contained in:
@@ -100,7 +100,7 @@ Registering the new extension is like registering core extensions:
|
||||
$twig->addExtension(new Project_Twig_Extension());
|
||||
|
||||
Filters can also be passed the current environment. You might have noticed
|
||||
that a filter is defined by a callable and a Boolean. If you change the
|
||||
that a filter is defined by a function name and a Boolean. If you change the
|
||||
Boolean to `true`, Twig will pass the current environment as the first
|
||||
argument to the filter call:
|
||||
|
||||
@@ -125,6 +125,23 @@ argument to the filter call:
|
||||
return str_rot13($string);
|
||||
}
|
||||
|
||||
Parameters passed to the filter are available as extra arguments to the
|
||||
function call:
|
||||
|
||||
[twig]
|
||||
{{ "Twig"|rot13('prefix_') }}
|
||||
|
||||
-
|
||||
|
||||
[php]
|
||||
function twig_compute_rot13(Twig_Environment $env, $string, $prefix = '')
|
||||
{
|
||||
// get the current charset for instance
|
||||
$charset = $env->getCharset();
|
||||
|
||||
return $prefix.str_rot13($string);
|
||||
}
|
||||
|
||||
Defining new Tags
|
||||
-----------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user