Пример #1
0
 public function testSetLayoutTokens()
 {
     $tokens = array('head' => '<title>Neechy</title>', 'top' => '<h1>Neechy</h1>', 'middle' => 'middle', 'bottom' => '<footer>bottom</footer>');
     $templater = new NeechyTemplater('no-theme');
     foreach ($tokens as $token => $content) {
         $templater->set($token, $content);
     }
     $output = $templater->render();
     foreach ($tokens as $token => $content) {
         $this->assertContains($content, $output);
     }
 }
Пример #2
0
 public function renderTemplate()
 {
     $templater = NeechyTemplater::load();
     $templater->page = 'NeechyPage';
     $templater->set('content', '<h1>Test</h1>');
     return $templater->render();
 }
Пример #3
0
 protected function respond($content, $status = 200)
 {
     # No AJAX response
     $templater = NeechyTemplater::load();
     $templater->page = $this->page;
     $templater->set('content', $content);
     $body = $templater->render();
     return new NeechyResponse($body, $status);
 }
Пример #4
0
 public static function load($theme = 'bootstrap')
 {
     if (!is_null(self::$instance)) {
         return self::$instance;
     } else {
         self::$instance = new NeechyTemplater($theme);
         return self::$instance;
     }
 }
Пример #5
0
 protected function respond($content, $status = 200)
 {
     if ($this->request->format == 'ajax') {
         $body = $content;
     } else {
         # Render web page
         $templater = NeechyTemplater::load();
         $templater->page = $this->page;
         $templater->set('content', $content);
         $body = $templater->render();
     }
     return new NeechyResponse($body, $status);
 }
Пример #6
0
 public static function create_on_install()
 {
     $pages_created = array();
     $pages_dir = NeechyPath::join(NEECHY_APP_PATH, 'templates/core_pages');
     $templater = NeechyTemplater::load();
     foreach (self::$core_pages as $name) {
         $basename = sprintf('%s.md.php', $name);
         $path = NeechyPath::join($pages_dir, $basename);
         $page_body = $templater->render_partial_by_path($path);
         $page = Page::find_by_title($name);
         $page->set('body', $page_body);
         $page->set('editor', NEECHY_USER);
         $page->save();
         $pages_created[] = $page;
     }
     return $pages_created;
 }
Пример #7
0
 public function editor_link()
 {
     if (!$this->editor) {
         return 'N/A';
     } else {
         $t = NeechyTemplater::load();
         $editor_name = $this->editor->field('name');
         return $t->neechy_link($editor_name);
     }
 }