blob: 1feafcdacf54065fc2472822849dea6330f92ffa (
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 mb_strpos($path, '.htm') !== false && file_exists($path);
}
}
|