[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 3 /** 4 * 5 * Tests the basic compiler 6 * 7 * @version $Id: compile.php 18360 2005-05-26 19:38:09Z mipmip $ 8 * 9 */ 10 11 function preprint($val) 12 { 13 echo "<pre>\n"; 14 print_r($val); 15 echo "</pre>\n"; 16 } 17 18 error_reporting(E_ALL); 19 20 // instantiate Savant 21 require_once 'Savant2.php'; 22 23 $conf = array( 24 'template_path' => 'templates', 25 'resource_path' => 'resources', 26 'restrict' => true // adding path restrictions! 27 ); 28 29 $savant =& new Savant2($conf); 30 31 // instantiate a compiler... 32 require_once 'Savant2/Savant2_Compiler_basic.php'; 33 $compiler =& new Savant2_Compiler_basic(); 34 $compiler->compileDir = '/tmp/'; 35 $compiler->forceCompile = true; 36 37 // and tell Savant to use it. 38 $savant->setCompiler($compiler); 39 40 // set up vars 41 $array = array( 42 'key0' => 'val0', 43 'key1' => 'val1', 44 'key2' => 'val2', 45 ); 46 47 $var1 = 'variable1'; 48 $var2 = 'variable2'; 49 $var3 = 'variable3'; 50 51 $ref1 = 'reference1'; 52 $ref2 = 'reference2'; 53 $ref3 = 'reference3'; 54 55 // assign vars 56 $savant->assign($var1, $var1); 57 $savant->assign($var2, $var2); 58 $savant->assign($var3, $var3); 59 60 // assigns $array to a variable $set 61 $savant->assign('set', $array); 62 63 // assigns the keys and values of array 64 $savant->assign($array); 65 66 // assign references 67 $savant->assignRef($ref1, $ref1); 68 $savant->assignRef($ref2, $ref2); 69 $savant->assignRef($ref3, $ref3); 70 71 echo "<h1>The 'good' template</h1>"; 72 $compiler->strict = false; 73 $result = $savant->display('compile.tpl.php'); 74 preprint($result); 75 76 echo "<h1>The 'bad' template</h1>"; 77 $compiler->strict = true; 78 $result = $savant->display('compile_bad.tpl.php'); 79 preprint($result); 80 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |