|
|
@@ -15,6 +15,7 @@ class Twig |
|
|
|
{ |
|
|
|
$loader = new FilesystemLoader($tmpl_folder); |
|
|
|
$this->twig = new Environment($loader, []); |
|
|
|
$this->variables = ['navbar' => [], 'messages' => [], 'footer' => []]; |
|
|
|
} |
|
|
|
|
|
|
|
protected function load($tmpl) |
|
|
@@ -22,15 +23,18 @@ class Twig |
|
|
|
return $this->twig->load($tmpl); |
|
|
|
} |
|
|
|
|
|
|
|
public function addToVar($data) |
|
|
|
// add block variables to the global variable bag |
|
|
|
public function addBlockVariable($block, $data) |
|
|
|
{ |
|
|
|
// TODO: Add data to variables |
|
|
|
//$this->variables = $data + |
|
|
|
$current = $this->variables[$block]; |
|
|
|
$new = array_merge($current, $data); |
|
|
|
$this->variables[$block] = $new; |
|
|
|
} |
|
|
|
|
|
|
|
public function render($tmpl, $vars) |
|
|
|
{ |
|
|
|
$template = $this->load($tmpl); |
|
|
|
$variables = $vars; // TODO: add global variables |
|
|
|
$variables = array_merge($this->variables, $vars); |
|
|
|
return $template->render($variables); |
|
|
|
} |
|
|
|
} |