예제 #1
0
 protected static function capture($kohana_view_filename, array $kohana_view_data)
 {
     $extension = func_get_args()[2];
     // is mustache ?
     // If it's not a mustache file, do the default:
     if ($extension == 'php') {
         return Kohana_View::capture($kohana_view_filename, $kohana_view_data);
     }
     // continue
     $vars = Arr::merge(self::kohanaVariables(), View::$_global_data);
     $vars = Arr::merge($vars, $kohana_view_data);
     $conf = Kohana::$config->load('mustache')->as_array();
     $mustache = new Mustache_Engine($conf);
     $tpl = $mustache->loadTemplate($kohana_view_filename);
     return $tpl->render($vars);
 }
예제 #2
0
파일: View.php 프로젝트: Xackery/coop
 /**
  * Captures the output that is generated when a view is included.
  * The view data will be extracted to make local variables. This method
  * is static to prevent object scope resolution.
  *
  * @param   string  filename
  * @param   array   variables
  * @return  string
  */
 protected static function capture($template, array $data)
 {
     if ($template == '') {
         return;
     }
     // Load Ksmarty only if it's activated and the template-extension matches
     $config = Kohana::$config->load('smarty');
     if ($config->integration && substr(strrchr($template, '.'), 1) == $config->template_ext) {
         // Get the Smarty instance
         $smarty = Ksmarty::instance();
         // Assign all the variables
         foreach ($data as $key => $value) {
             $smarty->assign($key, $value);
         }
         // Fetch the template output
         $output = $smarty->fetch($template);
     } else {
         $output = parent::capture($template, $data);
     }
     // Return the parsed output
     return $output;
 }