Example #1
0
 public static function read_by_params_and_render($params)
 {
     $solution = self::read_by_name($params['solution_name']);
     SiteStructure::set_page_title($solution['title']);
     $template = new Template($solution['content'], TRUE);
     $solution['content'] = $template->scrape($solution)->render();
     return $solution;
 }
Example #2
0
 public static function read_by_params_and_render($params)
 {
     if (isset($params['post_name'])) {
         $post = self::read_by_name($params['post_name']);
     } else {
         $post = self::read_by_date($params['year'], $params['month'], $params['day']);
     }
     SiteStructure::set_page_title($post['title']);
     $template = new Template($post['content'], TRUE);
     $post['content'] = $template->scrape($post)->render();
     return $post;
 }
Example #3
0
 public static function html($content, $data = [], $content_type = NULL)
 {
     $include = !isset($content_type);
     $content_type = isset($content_type) ? $content_type : 'text/html';
     header("Content-Type: {$content_type}");
     if (file_exists($content)) {
         $file = fopen($content, 'r') or die('Unable to open file!');
         $size = filesize($content);
         $content = fread($file, $size);
         fclose($file);
     }
     $template = new Template($content, TRUE);
     $scraped_template = $template->scrape($data);
     if ($include) {
         self::include_header();
     }
     echo $scraped_template->render($data);
     if ($include) {
         self::include_footer();
     }
 }
Example #4
0
 public static function render_doc_by_name($name, $context = [])
 {
     $template = new Template(Doc::by_name($name)['content'], TRUE);
     return $template->scrape($context)->render($context);
 }