private function make_data($cat, $posts)
 {
     $tmpl = $posts;
     $t = Application::templates()->templates_path() . '/';
     $tmpl['slug'] = $this->make_category_slug($cat);
     printLn('===> Category link: ' . $tmpl['slug']);
     $fixed_posts = [];
     foreach ($posts as $post) {
         $post['slug'] = $this->make_item_slug($post['title']);
         $fixed_posts[] = $post;
     }
     $tmpl['html'] = view($t . 'categories.phtml', ['name' => $cat, 'posts' => $fixed_posts]);
     return $tmpl;
 }
Example #2
0
 /**
  * Format a file to be rendered.
  * @param $file array | Json file as array.
  * @return array
  */
 private function make_data($file)
 {
     if (!array_key_exists('template', $file)) {
         throw new Exception('x> Current Post: ' . $file['title'] . ' does not have a template.');
     }
     $t = Application::templates()->template($file['template']);
     $data_folder = Application::data_folder();
     $template_name = $data_folder . '/templates/' . $t;
     $content_template = $data_folder . '/' . $file['content'];
     $render_content_with = Application::renders()->select($content_template);
     $render_with = Application::renders()->select($template_name);
     $tmpl['slug'] = $this->make_slug($file['title']);
     $tmpl['html'] = $render_with->render($template_name, ['content' => $render_content_with->render($content_template, ['post' => $file]), 'post' => $file]);
     $this->log_current_page($file['title'], $tmpl['slug']);
     return $tmpl;
 }
Example #3
0
 public function testGetDefaultTemplate()
 {
     $this->assertTrue(Application::templates()->template('default') != '');
 }