/framework/experimental/mizithra/Mizithra.php
PHP | 24 lines | 20 code | 2 blank | 2 comment | 1 complexity | 65ff8e883c97e797af7194c7b4f57b9e MD5 | raw file
1<?php 2class Mizithra 3{ 4 function display($template) 5 { 6 $content = file_get_contents(app_dir . '/mizithra/test.miz'); 7 8 $ldq = preg_quote('<?', '~'); 9 $rdq = preg_quote('?>', '~'); 10 preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $content, $match); 11 $text_blocks = preg_split("~{$ldq}.*?{$rdq}~s", $content); 12 13 // Interleave the compiled contents and text blocks to get the final result. 14 $compiled_content = ''; 15 $compiledTags = $match[1]; 16 for ($i = 0, $for_max = count($compiledTags); $i < $for_max; $i++) 17 { 18 $compiled_content .= $text_blocks[$i] . '<?php ' . $compiledTags[$i] . '?>'; 19 } 20 $compiled_content .= $text_blocks[$i]; 21 // echo $compiled_content; 22 eval('?>' . $compiled_content); 23 } 24}