PageRenderTime 18ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/framework/experimental/mizithra/Mizithra.php

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