/** * 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; }