Index: branches/RC/core/kernel/nparser/nparser.php =================================================================== diff -u -N -r10494 -r10580 --- branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 10494) +++ branches/RC/core/kernel/nparser/nparser.php (.../nparser.php) (revision 10580) @@ -27,6 +27,30 @@ { $data = file_get_contents($pre_parsed['tname']); + $this->CompileRaw($data, $pre_parsed['tname']); + + // saving compiled version + $compiled = fopen($pre_parsed['fname'], 'w'); + if (!fwrite($compiled, $this->Buffers[0])) { + trigger_error('Saving compiled template failed', E_USER_ERROR); + } + fclose($compiled); + return true; + } + + function Parse($raw_template, $name=null) + { + $this->CompileRaw($raw_template, $name); + ob_start(); + $_parser =& $this; + eval('?'.'>'.$this->Buffers[0]); + $output = ob_get_contents(); + ob_end_clean(); + return $output; + } + + function CompileRaw($data, $t_name) + { $code = "extract (\$_parser->Params);\n"; $this->Buffers[0] = '\n"; @@ -41,7 +65,7 @@ 'tag' => $tag_data[3][0], 'closing' => $tag_data[4][0], 'line' => substr_count(substr($data, 0, $tag_data[2][1]), "\n")+1, - 'file' => $pre_parsed['tname'], + 'file' => $t_name, ); // the idea is to count number of comment openings and closings before current tag @@ -74,14 +98,7 @@ // appending text data after last tag (after its closing pos), // if no tag was found at all ($tag_data is not set) - append the whole $data $this->Buffers[$this->Level] .= isset($tag_data) ? substr($data, $tag_data[4][1]+strlen($tag_data[4][0])) : $data; - - // saving compiled version - $compiled = fopen($pre_parsed['fname'], 'w'); - if (!fwrite($compiled, $this->Buffers[0])) { - trigger_error('Saving compiled template failed', E_USER_ERROR); - } - fclose($compiled); - return true; + $this->Buffers[$this->Level] = preg_replace('//s', '', $this->Buffers[$this->Level]); // remove hidden comments IB#23065 } function SplitParamsStr($params_str) @@ -242,12 +259,16 @@ ob_start(); $_parser =& $this; if ($pre_parsed['mode'] == 'file') { + if (false && $result = $this->Application->getCache('nparser', $pre_parsed['fname'])) { + return $result; + } include($pre_parsed['fname']); } else { eval('?'.'>'.$pre_parsed['content']); } $output = ob_get_contents(); + // $this->Application->setCache('nparser', $pre_parsed['fname'], $output); ob_end_clean(); return $output;