Beispiel #1
0
 /**
  * Метод подключения шаблонов
  * @param  string  $view   имя шаблона
  * @param  array   $params массив параметров
  * @param  boolean $return выводить или возвращать код
  * @return string          сформированный код
  */
 public static function view($template, $params = [], $return = false)
 {
     $blade = new Blade(APP . '/views', STORAGE . '/cache');
     if ($return) {
         return $blade->view()->make($template, $params)->render();
     } else {
         echo $blade->view()->make($template, $params)->render();
     }
 }
Beispiel #2
0
 /**
  * Include the template
  * @return string
  */
 public function blade_include($template)
 {
     if (!$template) {
         return $template;
     }
     // Noting to do here. Come back later.
     // all templates for our engine must live in the template directory
     if (stripos($template, get_template_directory()) === FALSE) {
         return $template;
     }
     if ($this->viewExpired($template)) {
         // get the base name
         $file = basename($template);
         // with a blade extension, we have to do this because blade wont recognize the root files without the .blade.php extension
         $blade = str_replace('.php', '.blade.php', $file);
         $blade_file = $this->view_cache . '/' . $blade;
         // get the code
         $code = file_get_contents($template);
         // add the code to the cached blade file
         file_put_contents($blade_file, $code);
         // blade friendly name
         $view = str_replace('.php', '', $file);
         // find a controller
         $controller = $this->getController($view);
         // run the blade code
         echo $this->blade->view()->make('cache.' . $view)->with(['data' => $controller ? $controller->process() : []])->render();
         // halt including
         return '';
     } else {
         // get the base name
         $file = basename($template);
         // blade friendly name
         $view = str_replace('.php', '', $file);
         // find a controller
         $controller = $this->getController($view);
         // run the blade code
         echo $this->blade->view()->make('cache.' . $view)->with(['data' => $controller ? $controller->process() : []])->render();
         // halt including
         return '';
     }
     // return an empty string to stop wordpress from including the template when we are doing it
     return $template;
 }
Beispiel #3
0
 public static function bladePage($page = '', $data = '', $obGetContents = false)
 {
     return Blade::view($page, $data, $obGetContents);
 }