blob: 75343bbd8085f385d4d98a69f775db6623a23740 (
plain)
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
|
<?php
namespace Engelsystem\Renderer;
class HtmlEngine implements EngineInterface
{
/**
* Render a template
*
* @param string $path
* @param mixed[] $data
* @return string
*/
public function get($path, $data = [])
{
$template = file_get_contents($path);
if (is_array($data)) {
foreach ($data as $name => $content) {
$template = str_replace('%' . $name . '%', $content, $template);
}
}
return $template;
}
/**
* @param string $path
* @return bool
*/
public function canRender($path)
{
return strpos($path, '.htm') && file_exists($path);
}
}
|