Пример #1
0
 /**
  * Display Output
  *
  * Processes and sends finalized output data to the browser along
  *
  * @param string $tpl Template Path
  * @return void
  */
 public function display($tpl = '')
 {
     if ('' === $tpl) {
         $tpl = CONTROLLER_NAME . '/' . ACTION_NAME;
     }
     $this->_viewPath = $this->_tplDir . $tpl . '.html';
     if (!Helper::isFile($this->_viewPath)) {
         throw new \Exception('Template is not existed.');
     }
     unset($tpl);
     ob_start();
     extract($this->_data, EXTR_OVERWRITE);
     include $this->_viewPath;
     $buffer = ob_get_contents();
     ob_get_clean();
     $output = Helper::comment() . preg_replace('|</body>.*?</html>|is', '', $buffer, -1, $count) . Trace::getSoul()->showTrace();
     if ($count > 0) {
         $output .= '</body></html>';
     }
     echo $output;
 }