forked from tolleiv/Repo-Activity-Monitor
-
Notifications
You must be signed in to change notification settings - Fork 2
/
TemplateEngine.php
45 lines (36 loc) · 837 Bytes
/
TemplateEngine.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
class TemplateEngine {
private $template = '';
/**
* @param string $template
*/
public function setTemplate($template) {
$this->template = $template;
}
/**
* @return string
*/
public function getTemplate() {
return $this->template;
}
public function __construct($templateName = '') {
if ($templateName != '') {
$this->loadTemplate($templateName);
}
}
public function loadTemplate($templateName) {
$this->template = file_get_contents(TEMPLATE_PATH.$templateName.'.html');
}
public function replaceMarkerArray($markerArray) {
foreach ($markerArray as $marker => $value) {
$this->template = str_replace('###' . $marker . '###', $value, $this->template);
}
}
public function replaceMarker ($marker, $value) {
$this->replaceMarkerArray(
array(
$marker => $value
)
);
}
}