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 = \Config::get('parser.View_Twig.views_paths', array(APPPATH . 'views')); array_unshift($views_paths, pathinfo($file, PATHINFO_DIRNAME)); 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(); } // Set the HtHaml Twig loader $filesyst = new Twig_Loader_Filesystem($views_paths); static::$_parser_loader = new MtHaml\Support\Twig\Loader(static::$_environment, $filesyst); $twig_lexer = new Twig_Lexer(static::$_parser, static::$_twig_lexer_conf); static::$_parser->setLexer($twig_lexer); //\Debug::dump(static::parser()); exit(); try { $result = static::parser()->render($view_name, $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; } /** * @access public * @static * @return Twig_Environment */ public static function parser() { if (empty(static::$_parser)) { parent::parser(); // Register Haml twig supports static::$_parser->addExtension(new MtHaml\Support\Twig\Extension()); // Store MtHaml environment static::$_environment = new MtHaml\Environment('twig', \Config::get('parser.View_HamlTwig.environment')); return static::$_parser; } return parent::parser(); } } // end of file hamltwig.php