/framework/experimental/mizithra/Mizithra.php
PHP | 24 lines | 20 code | 2 blank | 2 comment | 1 complexity | 65ff8e883c97e797af7194c7b4f57b9e MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
- <?php
- class Mizithra
- {
- function display($template)
- {
- $content = file_get_contents(app_dir . '/mizithra/test.miz');
-
- $ldq = preg_quote('<?', '~');
- $rdq = preg_quote('?>', '~');
- preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $content, $match);
- $text_blocks = preg_split("~{$ldq}.*?{$rdq}~s", $content);
-
- // Interleave the compiled contents and text blocks to get the final result.
- $compiled_content = '';
- $compiledTags = $match[1];
- for ($i = 0, $for_max = count($compiledTags); $i < $for_max; $i++)
- {
- $compiled_content .= $text_blocks[$i] . '<?php ' . $compiledTags[$i] . '?>';
- }
- $compiled_content .= $text_blocks[$i];
- // echo $compiled_content;
- eval('?>' . $compiled_content);
- }
- }