| @@ 8-24 (lines=17) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TestCompilerInterface; |
|
| 7 | ||
| 8 | class DivisibleByCompiler implements TestCompilerInterface |
|
| 9 | { |
|
| 10 | public function getName() |
|
| 11 | { |
|
| 12 | return 'divisibleby'; |
|
| 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(' % ') |
|
| 21 | ->subcompile($node->getNode('arguments')->getNode(0)) |
|
| 22 | ; |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| @@ 8-24 (lines=17) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TestCompilerInterface; |
|
| 7 | ||
| 8 | class SameAsCompiler implements TestCompilerInterface |
|
| 9 | { |
|
| 10 | public function getName() |
|
| 11 | { |
|
| 12 | return 'sameas'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_Node_Expression_Test $node) |
|
| 16 | { |
|
| 17 | $compiler |
|
| 18 | ->raw('(') |
|
| 19 | ->subcompile($node->getNode('node')) |
|
| 20 | ->raw(' === ') |
|
| 21 | ->subcompile($node->getNode('arguments')->getNode(0)) |
|
| 22 | ->raw(')'); |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||