/** * @access public * @static * @return void */ public static function _init() { // Include View_HamlTwig file(s) defined in config. $includes = \Config::get('parser.View_Twig.include'); foreach ((array) $includes as $include) { require $include; static::$loaded_files[$include] = true; } parent::_init(); MtHaml\Autoloader::register(); }
protected function generateResultHtml($extension) { HamlLoader::register(); $haml = new HamlGenerator('php', array('enable_escaper' => false)); $template = 'Resources/views/result.haml'; $targetFile = 'tmp/result.php'; $compiled = $haml->compileString(file_get_contents($template), $template); file_put_contents($targetFile, $compiled); // $results = $this->convertResultCommentsToHtml( // Logger::getResultArray($extension) // ); // $results = $this->convertResultCommentsToHtml(Logger::getIssueResults($extension)); $passedChecks = Logger::getPassedChecksOfIssueHandler($extension); $failedChecks = Logger::getFailedChecksOfIssueHandler($extension); // $failedChecks = $results['failedChecks']; // $score = $results['score']; ob_start(); include $targetFile; $result = ob_get_contents(); ob_end_clean(); $targetHtml = 'tmp/result.html'; file_put_contents($targetHtml, $result); }
<?php use MtHaml\Autoloader; use MtHaml\Environment; require_once __DIR__ . '/Autoloader.php'; Autoloader::register(); $haml = new MtHaml\Environment('php', array('enable_escaper' => false, 'escape_html' => false, 'escape_attrs' => false)); echo $haml->getOption("escape_html"); $remove_methods = true; foreach (glob(__DIR__ . "/../../app/views/*.haml") as $file) { $filename = basename($file); if ($filename !== "") { $compiled = $haml->compileString(file_get_contents($file), $filename); $filename_fixed = str_replace("haml", "php", $filename); if ($remove_methods) { preg_match_all('/\\<\\?php echo MtHaml\\\\Runtime::renderAttributes(.*)\\?\\>/', $compiled, $to_render, PREG_PATTERN_ORDER); foreach ($to_render[0] as $value) { $initial_value = $value; $remove_open_and_close = substr(substr($value, 6), 0, -3); preg_match_all('/MtHaml\\\\Runtime\\\\AttributeList::create\\(\\(.*\\"\\)\\)/', $remove_open_and_close, $replace_with_array); foreach ($replace_with_array as $attribute_list_method) { if (!empty($attribute_list_method)) { $item = $attribute_list_method[0]; $attr = preg_replace('/\\"\\)\\)/', "", preg_replace('/MtHaml\\\\Runtime\\\\AttributeList::create\\(\\(/', "", $item)); $remove_quotes = str_replace('"', "", $attr); $separate_attributes = explode(":", $remove_quotes); $attributes = array(trim($separate_attributes[0]), trim($separate_attributes[1])); $value = str_replace($attribute_list_method, $attributes, $value); } } $to_eval = substr(substr($value, 11), 0, -3);