Completed
Push — master ( 0db593...5f0535 )
by Jean-Christophe
01:58
created

MicroTemplateEngine::render()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 4
nop 3
1
<?php
2
3
namespace Ubiquity\views\engine\micro;
4
5
use Ubiquity\views\engine\TemplateEngine;
6
use Ubiquity\controllers\Startup;
7
8
class MicroTemplateEngine extends TemplateEngine {
9
	private $viewsFolder;
10
11
	public function __construct() {
12
		$this->viewsFolder=ROOT . DS . "views/";
13
	}
14
15
	/*
16
	 * (non-PHPdoc)
17
	 * @see TemplateEngine::render()
18
	 */
19
	public function render($viewName, $pData, $asString) {
20
		$config=Startup::getConfig();
21
		$fileName=$this->viewsFolder . $viewName;
22
		if (is_array($pData)) {
23
			extract($pData);
24
		}
25
		$tpl=new TemplateParser($fileName);
26
		$content=eval('?>' . $tpl->__toString());
27
		if ($asString)
28
			return $content;
29
		else
30
			echo $content;
31
	}
32
	public function getBlockNames($templateName) {
33
		return [];
34
	}
35
36
}
37