Revision 1852
Added by darkviper over 11 years ago
Include.php | ||
---|---|---|
39 | 39 |
; |
40 | 40 |
} |
41 | 41 |
|
42 |
$this->addGetTemplate($compiler); |
|
43 |
|
|
44 |
$compiler->raw('->display('); |
|
45 |
|
|
46 |
$this->addTemplateArguments($compiler); |
|
47 |
|
|
48 |
$compiler->raw(");\n"); |
|
49 |
|
|
50 |
if ($this->getAttribute('ignore_missing')) { |
|
51 |
$compiler |
|
52 |
->outdent() |
|
53 |
->write("} catch (Twig_Error_Loader \$e) {\n") |
|
54 |
->indent() |
|
55 |
->write("// ignore missing template\n") |
|
56 |
->outdent() |
|
57 |
->write("}\n\n") |
|
58 |
; |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
protected function addGetTemplate(Twig_Compiler $compiler) |
|
63 |
{ |
|
42 | 64 |
if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) { |
43 | 65 |
$compiler |
44 | 66 |
->write("\$this->env->loadTemplate(") |
45 | 67 |
->subcompile($this->getNode('expr')) |
46 |
->raw(")->display(")
|
|
68 |
->raw(")") |
|
47 | 69 |
; |
48 | 70 |
} else { |
49 | 71 |
$compiler |
50 | 72 |
->write("\$template = \$this->env->resolveTemplate(") |
51 | 73 |
->subcompile($this->getNode('expr')) |
52 | 74 |
->raw(");\n") |
53 |
->write('$template->display(')
|
|
75 |
->write('$template') |
|
54 | 76 |
; |
55 | 77 |
} |
78 |
} |
|
56 | 79 |
|
80 |
protected function addTemplateArguments(Twig_Compiler $compiler) |
|
81 |
{ |
|
57 | 82 |
if (false === $this->getAttribute('only')) { |
58 | 83 |
if (null === $this->getNode('variables')) { |
59 | 84 |
$compiler->raw('$context'); |
... | ... | |
71 | 96 |
$compiler->subcompile($this->getNode('variables')); |
72 | 97 |
} |
73 | 98 |
} |
74 |
|
|
75 |
$compiler->raw(");\n"); |
|
76 |
|
|
77 |
if ($this->getAttribute('ignore_missing')) { |
|
78 |
$compiler |
|
79 |
->outdent() |
|
80 |
->write("} catch (Twig_Error_Loader \$e) {\n") |
|
81 |
->indent() |
|
82 |
->write("// ignore missing template\n") |
|
83 |
->outdent() |
|
84 |
->write("}\n\n") |
|
85 |
; |
|
86 |
} |
|
87 | 99 |
} |
88 | 100 |
} |
Also available in: Unified diff
updated Twig template engine to stable version 1.11.1 step2