PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/A/Template/Eval.php

http://skeleton.googlecode.com/
PHP | 42 lines | 24 code | 5 blank | 13 comment | 5 complexity | ca324bfa21678f1451e2a9cf9a216508 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * Eval.php
  4. *
  5. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  6. * @link http://skeletonframework.com/
  7. */
  8. /**
  9. * A_Template_Eval
  10. *
  11. * Template class that loads and eval()'s PHP templates. Templates can have blocks.
  12. *
  13. * @package A_Template
  14. */
  15. class A_Template_Eval extends A_Template_File implements A_Renderer
  16. {
  17. protected $str = '';
  18. public function render($block='')
  19. {
  20. if ($this->auto_blocks) {
  21. $this->makeBlocks();
  22. } else {
  23. $this->loadTemplate();
  24. }
  25. if (is_array($this->data) && isset($this->blocks[$block])) {
  26. $this->str =& $this->blocks[$block];
  27. return($this->evalStr());
  28. } else {
  29. return $this->blocks[$block];
  30. }
  31. }
  32. public function evalStr($_template_eval_str)
  33. {
  34. extract($this->data);
  35. eval('return "' . addslashes($this->str) . '";');
  36. }
  37. }