diff options
Diffstat (limited to 'src/Renderer/HtmlEngine.php')
-rw-r--r-- | src/Renderer/HtmlEngine.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Renderer/HtmlEngine.php b/src/Renderer/HtmlEngine.php new file mode 100644 index 00000000..4a48e1f0 --- /dev/null +++ b/src/Renderer/HtmlEngine.php @@ -0,0 +1,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, '.html') && file_exists($path); + } +} |