Last active
May 3, 2017 04:23
-
-
Save igancev/c8d462a7950efde006c781401f720e2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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