ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
TemplateWrapper.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
18{
19 private $env;
20 private $template;
21
29 {
30 $this->env = $env;
31 $this->template = $template;
32 }
33
41 public function render($context = array())
42 {
43 return $this->template->render($context);
44 }
45
51 public function display($context = array())
52 {
53 $this->template->display($context);
54 }
55
64 public function hasBlock($name, $context = array())
65 {
66 return $this->template->hasBlock($name, $context);
67 }
68
76 public function getBlockNames($context = array())
77 {
78 return $this->template->getBlockNames($context);
79 }
80
89 public function renderBlock($name, $context = array())
90 {
91 $context = $this->env->mergeGlobals($context);
92 $level = ob_get_level();
93 ob_start();
94 try {
95 $this->template->displayBlock($name, $context);
96 } catch (Exception $e) {
97 while (ob_get_level() > $level) {
98 ob_end_clean();
99 }
100
101 throw $e;
102 } catch (Throwable $e) {
103 while (ob_get_level() > $level) {
104 ob_end_clean();
105 }
106
107 throw $e;
108 }
109
110 return ob_get_clean();
111 }
112
119 public function displayBlock($name, $context = array())
120 {
121 $this->template->displayBlock($name, $this->env->mergeGlobals($context));
122 }
123
127 public function getSourceContext()
128 {
129 return $this->template->getSourceContext();
130 }
131}
132
133class_alias('Twig_TemplateWrapper', 'Twig\TemplateWrapper', false);
An exception for terminatinating execution or to throw for unit testing.
Stores the Twig configuration.
Definition: Environment.php:18
Exposes a template to userland.
displayBlock($name, $context=array())
Displays a template block.
__construct(Twig_Environment $env, Twig_Template $template)
This method is for internal use only and should never be called directly (use Twig_Environment::load(...
display($context=array())
Displays the template.
getBlockNames($context=array())
Returns defined block names in the template.
hasBlock($name, $context=array())
Checks if a block is defined.
render($context=array())
Renders the template.
renderBlock($name, $context=array())
Renders a template block.
Default base class for compiled templates.
Definition: Template.php:25
$context
Definition: webdav.php:25