FuelPHP Bin
protected function process_file($file_override = false) { $file = $file_override ?: $this->file_name; $local_data = $this->get_data('local'); $global_data = $this->get_data('global'); // Extract View name/extension (ex. "template.twig") $view_name = pathinfo($file, PATHINFO_BASENAME); // Twig Loader $views_paths = array_reverse(array_unique(\Config::get('parser.View_Twig.views_paths'))); if ( ! empty($global_data)) { foreach ($global_data as $key => $value) { static::parser()->addGlobal($key, $value); } } else { // Init the parser if you have no global data static::parser(); } $twig_lexer = new Twig_Lexer(static::$_parser, static::$_twig_lexer_conf); static::$_parser->setLexer($twig_lexer); try { $result = static::parser()->loadTemplate($view_name)->render($local_data); } catch (\Exception $e) { // Delete the output buffer & re-throw the exception ob_end_clean(); throw $e; } $this->unsanitize($local_data); $this->unsanitize($global_data); return $result; }