pachanga
Новичок
аналог smarty, но в 130 раз меньше
PHP:
<?php
class php_template {
var $template_dir = '';
var $file_name = '';
var $vars = array();
function php_template() {}
function assign($name, $value) {
$this->vars[$name] = $value;
}
function set_file_name($name) {
$this->file_name = $name;
}
function set_template_dir($name) {
$this->template_dir = $name;
}
function set_cache_dir($name) {
$this->cache_dir = $name;
}
function parse() {
$t = array();
$old_error_reporting = error_reporting(E_ALL & ~(E_WARNING | E_NOTICE));
ob_start();
$str = '';
foreach($this->vars as $var_name => $var_value) {
$str = "$var_name";
parse_str($str);
$t[$var_name] = $var_value;
}
$file_name = $this->template_dir.'/'.$this->file_name;
include($this->template_dir.'/'.$this->file_name);
$str = ob_get_contents();
ob_end_clean();
error_reporting($old_error_reporting);
return $str;
}
}
?>