Example #1
0
 public static function output($vars = '')
 {
     // variables
     $template = new Template($vars);
     $cache = null;
     $id = "{$_SERVER['HTTP_HOST']}/html/" . $template->hash;
     // get available cache (if applicable)
     if ($template->canCache()) {
         // first thing, check if there's a cached version of the template
         $cache = self::getCache($id);
     }
     //$cache = false;
     if (!empty($cache) && !DEBUG) {
         echo $cache;
         return;
     }
     // continue processing
     $template->setupClient();
     //
     $GLOBALS['body'] = $template->vars["body"];
     $GLOBALS['head'] = $template->get("head");
     $GLOBALS['foot'] = $template->get("foot");
     // compile the page with the existing data
     $output = $template->do_fetch($template->file, $template->vars);
     // post-process (in debug with limited features)
     $output = $template->process($output);
     // output the final markup - clear whitespace (if not in debug mode)
     echo $output;
     // set the cache for later use
     self::setCache($id, $output);
 }