14 if (!isset ($this->parsers [$viewName])) {
15 $this->parsers [$viewName] =
new TemplateParser ($this->viewsFolder . $viewName);
17 return $this->parsers [$viewName];
21 $this->viewsFolder = \ROOT . \DS .
'views' . \DS;
28 public function render(
string $viewName, ?array $pData = [],
bool $asString =
false) {
29 if (\is_array($pData)) {
32 $content = eval (
'?>' . $this->getTemplateParser($viewName)->__toString());
43 public function getCode(
string $templateName): string {
44 $fileName = $this->viewsFolder . $templateName;
45 return UFileSystem::load($fileName);
48 public function exists(
string $name): bool {
49 $filename = $this->viewsFolder . $name;
50 return \file_exists($filename);
53 public function addFunction(
string $name, $callback, array $options = []): void {
54 throw new \BadMethodCallException(
'addFunction method has no sense with MicroTemplateEngine');
57 protected function addFilter(
string $name, $callback, array $options = []): void {
58 throw new \BadMethodCallException(
'addFilter method has no sense with MicroTemplateEngine');
62 throw new \BadMethodCallException(
'addExtension method has no sense with MicroTemplateEngine');
File system utilities Ubiquity\utils\base$UFileSystem This class is part of Ubiquity.
Abstract template engine.
Ubiquity abstract TemplateGenerator class.
getBlockNames(string $templateName)
Returns the defined block names.
addFilter(string $name, $callback, array $options=[])
getCode(string $templateName)
Returns the source code of the template.
addFunction(string $name, $callback, array $options=[])
render(string $viewName, ?array $pData=[], bool $asString=false)
Renders a view.
exists(string $name)
Checks if we have the source code of a template, given its name.
getTemplateParser(string $viewName)