<?php
// last edit: 02.05.2018
/**
 * Реализация Представления
 *
 */
class View {

    static $_DATA = [];
    static $default = 'index.html';

    var $Template = 'empty.html';
    var $Data = [];

    function  __construct() {

        TemplateEngine::$path = SYS::getPath('template') ?: 'template';
        TemplateEngine::$pathtmp = SYS::getPath('cache') ?: TemplateEngine::$path.'/cache';
        TemplateEngine::init();

    }

    function display() {
        return TemplateEngine::view($this->Template, $this->Data);
    }

}


function view($template, $data = []){
    $temp = new View;
    $temp->Template = $template;
    $temp->Data = array_merge(View::$_DATA, $data);
    return $temp->display();
}


function defView( $data = []){
    return view(View::$default, $data);
}