Skip to content

Instantly share code, notes, and snippets.

@igancev
Last active May 3, 2017 04:23
Show Gist options
  • Save igancev/c8d462a7950efde006c781401f720e2f to your computer and use it in GitHub Desktop.
Save igancev/c8d462a7950efde006c781401f720e2f to your computer and use it in GitHub Desktop.
<?php
/**
* Хэлпер для простого рендера шаблонов
*
* Class Templater
* @author igancev
* @email [email protected]
*/
class Templater
{
/**
* Простой рендер по темплэйту
* @param array $params параметры массива будут преобразованы в переменные внутри шаблона
* @param string $templatePath путь к шаблону
* @param bool $return возвращать значение как строку или печатать на странице
*
* @return string|void
*/
public static function render($templatePath, array $params = array(), $return = true)
{
extract($params);
if($return)
{
ob_start();
}
include($templatePath);
if($return)
{
return ob_get_clean();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment