You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
702 B
PHP

<?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);
}
}