| @@ 8-28 (lines=21) @@ | ||
| 5 | use TwigJs\JsCompiler; |
|
| 6 | use TwigJs\TypeCompilerInterface; |
|
| 7 | ||
| 8 | class FlushCompiler implements TypeCompilerInterface |
|
| 9 | { |
|
| 10 | public function getType() |
|
| 11 | { |
|
| 12 | return 'Twig_Node_Flush'; |
|
| 13 | } |
|
| 14 | ||
| 15 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 16 | { |
|
| 17 | if (!$node instanceof \Twig_Node_Flush) { |
|
| 18 | throw new \RuntimeException( |
|
| 19 | sprintf( |
|
| 20 | '$node must be an instanceof of \Twig_Node_Flush, but got "%s".', |
|
| 21 | get_class($node) |
|
| 22 | ) |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | ||
| 26 | throw new \LogicException('Flushing is not supported in Javascript templates.'); |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||
| @@ 24-58 (lines=35) @@ | ||
| 21 | use TwigJs\JsCompiler; |
|
| 22 | use TwigJs\TypeCompilerInterface; |
|
| 23 | ||
| 24 | class SandboxCompiler implements TypeCompilerInterface |
|
| 25 | { |
|
| 26 | public function getType() |
|
| 27 | { |
|
| 28 | return 'Twig_Node_Sandbox'; |
|
| 29 | } |
|
| 30 | ||
| 31 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 32 | { |
|
| 33 | if (!$node instanceof \Twig_Node_Sandbox) { |
|
| 34 | throw new \RuntimeException( |
|
| 35 | sprintf( |
|
| 36 | '$node must be an instanceof of \Twig_Node_Sandbox, but got "%s".', |
|
| 37 | get_class($node) |
|
| 38 | ) |
|
| 39 | ); |
|
| 40 | } |
|
| 41 | ||
| 42 | // $compiler |
|
| 43 | // ->addDebugInfo($this) |
|
| 44 | // ->write("\$sandbox = \$this->env->getExtension('sandbox');\n") |
|
| 45 | // ->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n") |
|
| 46 | // ->indent() |
|
| 47 | // ->write("\$sandbox->enableSandbox();\n") |
|
| 48 | // ->outdent() |
|
| 49 | // ->write("}\n") |
|
| 50 | // ->subcompile($this->getNode('body')) |
|
| 51 | // ->write("if (!\$alreadySandboxed) {\n") |
|
| 52 | // ->indent() |
|
| 53 | // ->write("\$sandbox->disableSandbox();\n") |
|
| 54 | // ->outdent() |
|
| 55 | // ->write("}\n") |
|
| 56 | // ; |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||
| @@ 24-51 (lines=28) @@ | ||
| 21 | use TwigJs\JsCompiler; |
|
| 22 | use TwigJs\TypeCompilerInterface; |
|
| 23 | ||
| 24 | class SetTempCompiler implements TypeCompilerInterface |
|
| 25 | { |
|
| 26 | public function getType() |
|
| 27 | { |
|
| 28 | return 'Twig_Node_SetTemp'; |
|
| 29 | } |
|
| 30 | ||
| 31 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
| 32 | { |
|
| 33 | if (!$node instanceof \Twig_Node_SetTemp) { |
|
| 34 | throw new \RuntimeException( |
|
| 35 | sprintf( |
|
| 36 | '$node must be an instanceof of \Twig_Node_SetTemp, but got "%s".', |
|
| 37 | get_class($node) |
|
| 38 | ) |
|
| 39 | ); |
|
| 40 | } |
|
| 41 | ||
| 42 | /* |
|
| 43 | This method has been gutted as part of schmittjoh/twig.js#12 |
|
| 44 | ||
| 45 | Assigning context variables to temporary "tmp_" variables is a |
|
| 46 | performance optimization that was misbehaving and causing trouble with |
|
| 47 | variables in different scopes, so it has been removed until it can be |
|
| 48 | implemented reliably. |
|
| 49 | */ |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||