mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 03:57:21 +00:00
fix node class namespace
This commit is contained in:
committed by
GitHub
parent
4ba33d8950
commit
06ff4bdf9a
+10
-4
@@ -339,14 +339,20 @@ When creating tests you can use the ``node_class`` option to provide custom test
|
||||
compilation. This is useful if your test can be compiled into PHP primitives.
|
||||
This is used by many of the tests built into Twig::
|
||||
|
||||
$twig = new \Twig\Environment($loader);
|
||||
$test = new \Twig\TwigTest(
|
||||
namespace App;
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Node\Expression\TestExpression;
|
||||
use Twig\TwigTest;
|
||||
|
||||
$twig = new Environment($loader);
|
||||
$test = new TwigTest(
|
||||
'odd',
|
||||
null,
|
||||
['node_class' => '\Twig\Node\Expression\Test\OddTest']);
|
||||
['node_class' => OddTestExpression::class]);
|
||||
$twig->addTest($test);
|
||||
|
||||
class Twig_Node_Expression_Test_Odd extends \Twig\Node\Expression\TestExpression
|
||||
class OddTestExpression extends TestExpression
|
||||
{
|
||||
public function compile(\Twig\Compiler $compiler)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user