+// Main compilation loop
+function doFinalCompilation ($code, $insertComments = true) {
+ // Insert comments?
+ enableTemplateHtml($insertComments);
+
+ // Init counter
+ $cnt = 0;
+
+ // Compile all out
+ while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($cnt < 3)) {
+ // Init common variables
+ $content = array();
+ $newContent = '';
+
+ // Compile it
+ //* DEBUG: */ print '<pre>'.htmlentities($code).'</pre>';
+ $eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code))) . '";';
+ //* DEBUG: */ die('<pre>'.htmlentities($eval).'</pre>');
+ eval($eval);
+ //* DEBUG: */ die('<pre>'.htmlentities($newContent).'</pre>');
+
+ // Was that eval okay?
+ if (empty($newContent)) {
+ // Something went wrong!
+ debug_report_bug(__FUNCTION__, __LINE__, 'Evaluation error:<pre>' . linenumberCode($eval) . '</pre>', false);
+ } // END - if
+
+ // Use it again
+ $code = $newContent;
+
+ // Count round
+ $cnt++;
+ } // END - while
+
+ // Return the compiled code
+ return $code;
+}
+