PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/yet-another-photoblog/lib/Savant2-2.4.3/Savant2/tests/compile.php

https://github.com/Mercedes/ratonesytortillas
PHP | 80 lines | 48 code | 17 blank | 15 comment | 0 complexity | c45f81c917dc91d60365132ccdf3317b MD5 | raw file
  1. <?php
  2. /**
  3. *
  4. * Tests the basic compiler
  5. *
  6. * @version $Id: compile.php,v 1.6 2005/01/07 22:05:38 pmjones Exp $
  7. *
  8. */
  9. function preprint($val)
  10. {
  11. echo "<pre>\n";
  12. print_r($val);
  13. echo "</pre>\n";
  14. }
  15. error_reporting(E_ALL);
  16. // instantiate Savant
  17. require_once 'Savant2.php';
  18. $conf = array(
  19. 'template_path' => 'templates',
  20. 'resource_path' => 'resources',
  21. 'restrict' => true // adding path restrictions!
  22. );
  23. $savant =& new Savant2($conf);
  24. // instantiate a compiler...
  25. require_once 'Savant2/Savant2_Compiler_basic.php';
  26. $compiler =& new Savant2_Compiler_basic();
  27. $compiler->compileDir = '/tmp/';
  28. $compiler->forceCompile = true;
  29. // and tell Savant to use it.
  30. $savant->setCompiler($compiler);
  31. // set up vars
  32. $array = array(
  33. 'key0' => 'val0',
  34. 'key1' => 'val1',
  35. 'key2' => 'val2',
  36. );
  37. $var1 = 'variable1';
  38. $var2 = 'variable2';
  39. $var3 = 'variable3';
  40. $ref1 = 'reference1';
  41. $ref2 = 'reference2';
  42. $ref3 = 'reference3';
  43. // assign vars
  44. $savant->assign($var1, $var1);
  45. $savant->assign($var2, $var2);
  46. $savant->assign($var3, $var3);
  47. // assigns $array to a variable $set
  48. $savant->assign('set', $array);
  49. // assigns the keys and values of array
  50. $savant->assign($array);
  51. // assign references
  52. $savant->assignRef($ref1, $ref1);
  53. $savant->assignRef($ref2, $ref2);
  54. $savant->assignRef($ref3, $ref3);
  55. echo "<h1>The 'good' template</h1>";
  56. $compiler->strict = false;
  57. $result = $savant->display('compile.tpl.php');
  58. preprint($result);
  59. echo "<h1>The 'bad' template</h1>";
  60. $compiler->strict = true;
  61. $result = $savant->display('compile_bad.tpl.php');
  62. preprint($result);
  63. ?>