@@ 23-40 (lines=18) @@ | ||
20 | ||
21 | use TwigJs\JsCompiler; |
|
22 | ||
23 | class BodyCompiler extends NodeCompiler |
|
24 | { |
|
25 | public function getType() |
|
26 | { |
|
27 | return 'Twig_Node_Body'; |
|
28 | } |
|
29 | ||
30 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
31 | { |
|
32 | if (!$node instanceof \Twig_Node_Body) { |
|
33 | throw new \RuntimeException( |
|
34 | sprintf('$node must be an instanceof of \Twig_Node_Body, but got "%s".', get_class($node)) |
|
35 | ); |
|
36 | } |
|
37 | ||
38 | return parent::compile($compiler, $node); |
|
39 | } |
|
40 | } |
|
41 |
@@ 23-81 (lines=59) @@ | ||
20 | ||
21 | use TwigJs\JsCompiler; |
|
22 | ||
23 | class SandboxedGoogleCompiler extends GoogleCompiler |
|
24 | { |
|
25 | public function getType() |
|
26 | { |
|
27 | return 'Twig_Node_SandboxedModule'; |
|
28 | } |
|
29 | ||
30 | public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) |
|
31 | { |
|
32 | if (!$node instanceof \Twig_Node_SandboxedModule) { |
|
33 | throw new \RuntimeException( |
|
34 | sprintf( |
|
35 | '$node must be an instanceof of \Twig_Node_SandboxedModule, but got "%s".', |
|
36 | get_class($node) |
|
37 | ) |
|
38 | ); |
|
39 | } |
|
40 | ||
41 | parent::compile($compiler, $node); |
|
42 | } |
|
43 | ||
44 | // protected function compileDisplayBody(Twig_Compiler $compiler) |
|
45 | // { |
|
46 | // if (null === $this->getNode('parent')) { |
|
47 | // $compiler->write("\$this->checkSecurity();\n"); |
|
48 | // } |
|
49 | // |
|
50 | // parent::compileDisplayBody($compiler); |
|
51 | // } |
|
52 | // |
|
53 | // protected function compileDisplayFooter(Twig_Compiler $compiler) |
|
54 | // { |
|
55 | // parent::compileDisplayFooter($compiler); |
|
56 | // |
|
57 | // $compiler |
|
58 | // ->write("protected function checkSecurity() {\n") |
|
59 | // ->indent() |
|
60 | // ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n") |
|
61 | // ->indent() |
|
62 | // ->write(!$this->usedTags ? "array(),\n" : "array('".implode('\', \'', $this->usedTags)."'),\n") |
|
63 | // ->write(!$this->usedFilters ? "array(),\n" : "array('".implode('\', \'', $this->usedFilters)."'),\n") |
|
64 | // ->write(!$this->usedFunctions ? "array()\n" : "array('".implode('\', \'', $this->usedFunctions)."')\n") |
|
65 | // ->outdent() |
|
66 | // ->write(");\n") |
|
67 | // ; |
|
68 | // |
|
69 | // if (null !== $this->getNode('parent')) { |
|
70 | // $compiler |
|
71 | // ->raw("\n") |
|
72 | // ->write("\$this->parent->checkSecurity();\n") |
|
73 | // ; |
|
74 | // } |
|
75 | // |
|
76 | // $compiler |
|
77 | // ->outdent() |
|
78 | // ->write("}\n\n") |
|
79 | // ; |
|
80 | // } |
|
81 | } |
|
82 |