| @@ 8-23 (lines=16) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TestCompilerInterface; |
|
| 7 | ||
| 8 | class EmptyCompiler implements TestCompilerInterface |
|
| 9 | { |
|
| 10 | public function getName() |
|
| 11 | { |
|
| 12 | return 'empty'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_Node_Expression_Test $node) |
|
| 16 | { |
|
| 17 | $compiler |
|
| 18 | ->raw('twig.empty(') |
|
| 19 | ->subcompile($node->getNode('node')) |
|
| 20 | ->raw(')') |
|
| 21 | ; |
|
| 22 | } |
|
| 23 | } |
|
| 24 | ||
| @@ 8-23 (lines=16) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TestCompilerInterface; |
|
| 7 | ||
| 8 | class EvenCompiler implements TestCompilerInterface |
|
| 9 | { |
|
| 10 | public function getName() |
|
| 11 | { |
|
| 12 | return 'even'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_Node_Expression_Test $node) |
|
| 16 | { |
|
| 17 | $compiler |
|
| 18 | ->raw('(0 === ') |
|
| 19 | ->subcompile($node->getNode('node')) |
|
| 20 | ->raw(' % 2)') |
|
| 21 | ; |
|
| 22 | } |
|
| 23 | } |
|
| 24 | ||
| @@ 8-23 (lines=16) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TestCompilerInterface; |
|
| 7 | ||
| 8 | class NoneCompiler implements TestCompilerInterface |
|
| 9 | { |
|
| 10 | public function getName() |
|
| 11 | { |
|
| 12 | return 'none'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_Node_Expression_Test $node) |
|
| 16 | { |
|
| 17 | $compiler |
|
| 18 | ->raw('(null === ') |
|
| 19 | ->subcompile($node->getNode('node')) |
|
| 20 | ->raw(')') |
|
| 21 | ; |
|
| 22 | } |
|
| 23 | } |
|
| 24 | ||
| @@ 8-23 (lines=16) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TestCompilerInterface; |
|
| 7 | ||
| 8 | class OddCompiler implements TestCompilerInterface |
|
| 9 | { |
|
| 10 | public function getName() |
|
| 11 | { |
|
| 12 | return 'odd'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_Node_Expression_Test $node) |
|
| 16 | { |
|
| 17 | $compiler |
|
| 18 | ->raw('1 === ') |
|
| 19 | ->subcompile($node->getNode('node')) |
|
| 20 | ->raw(' % 2') |
|
| 21 | ; |
|
| 22 | } |
|
| 23 | } |
|
| 24 | ||