Changeset 929
- Timestamp:
- 05/07/08 01:01:41 (2 months ago)
- Files:
-
- branches/1.0.x/lib/jelix/tpl/jTplCompiler.class.php (modified) (4 diffs)
- branches/1.0.x/lib/jelix/tpl/jTplCompiler.class.php (modified) (4 diffs)
- branches/1.0.x/lib/jelix/tpl/jTplCompiler.class.php (modified) (4 diffs)
- branches/1.0.x/lib/jelix/tpl/jTplCompiler.class.php (modified) (4 diffs)
- branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php (modified) (3 diffs)
- branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php (modified) (3 diffs)
- branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php (modified) (3 diffs)
- branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php (modified) (3 diffs)
- branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php (modified) (1 diff)
- branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php (modified) (1 diff)
- branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php (modified) (1 diff)
- branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php (modified) (1 diff)
- trunk/lib/jelix/tpl/jTplCompiler.class.php (modified) (4 diffs)
- trunk/lib/jelix/tpl/jTplCompiler.class.php (modified) (4 diffs)
- trunk/lib/jelix/tpl/jTplCompiler.class.php (modified) (4 diffs)
- trunk/lib/jelix/tpl/jTplCompiler.class.php (modified) (4 diffs)
- trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php (modified) (3 diffs)
- trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php (modified) (3 diffs)
- trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php (modified) (3 diffs)
- trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php (modified) (3 diffs)
- trunk/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0.x/lib/jelix/tpl/jTplCompiler.class.php
r742 r929 4 4 * @subpackage jtpl 5 5 * @author Laurent Jouanneau 6 * @contributor Mathaud Loic ( version standalone), Dominique Papin7 * @copyright 2005-200 7Laurent Jouanneau6 * @contributor Mathaud Loic (standalone version), Dominique Papin 7 * @copyright 2005-2008 Laurent Jouanneau 8 8 * @copyright 2006 Mathaud Loic, 2007 Dominique Papin 9 9 * @link http://www.jelix.org … … 308 308 break; 309 309 case 'foreach': 310 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!' )).'):';310 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!','(')).'):'; 311 311 array_push($this->_blockStack,'foreach'); 312 312 break; … … 316 316 break; 317 317 case 'for': 318 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array( )) .'):';318 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array('(')) .'):'; 319 319 array_push($this->_blockStack,'for'); 320 320 break; … … 470 470 } elseif ($inLocale && ($tok=='.' || $tok =='~') ) { 471 471 $locale.=$tok; 472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!')) {472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!' && $tok != '(')) { 473 473 $this->doError2('errors.tpl.tag.character.invalid', $this->_currentTag, $tok); 474 474 } elseif ($tok =='(') { branches/1.0.x/lib/jelix/tpl/jTplCompiler.class.php
r742 r929 4 4 * @subpackage jtpl 5 5 * @author Laurent Jouanneau 6 * @contributor Mathaud Loic ( version standalone), Dominique Papin7 * @copyright 2005-200 7Laurent Jouanneau6 * @contributor Mathaud Loic (standalone version), Dominique Papin 7 * @copyright 2005-2008 Laurent Jouanneau 8 8 * @copyright 2006 Mathaud Loic, 2007 Dominique Papin 9 9 * @link http://www.jelix.org … … 308 308 break; 309 309 case 'foreach': 310 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!' )).'):';310 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!','(')).'):'; 311 311 array_push($this->_blockStack,'foreach'); 312 312 break; … … 316 316 break; 317 317 case 'for': 318 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array( )) .'):';318 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array('(')) .'):'; 319 319 array_push($this->_blockStack,'for'); 320 320 break; … … 470 470 } elseif ($inLocale && ($tok=='.' || $tok =='~') ) { 471 471 $locale.=$tok; 472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!')) {472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!' && $tok != '(')) { 473 473 $this->doError2('errors.tpl.tag.character.invalid', $this->_currentTag, $tok); 474 474 } elseif ($tok =='(') { branches/1.0.x/lib/jelix/tpl/jTplCompiler.class.php
r742 r929 4 4 * @subpackage jtpl 5 5 * @author Laurent Jouanneau 6 * @contributor Mathaud Loic ( version standalone), Dominique Papin7 * @copyright 2005-200 7Laurent Jouanneau6 * @contributor Mathaud Loic (standalone version), Dominique Papin 7 * @copyright 2005-2008 Laurent Jouanneau 8 8 * @copyright 2006 Mathaud Loic, 2007 Dominique Papin 9 9 * @link http://www.jelix.org … … 308 308 break; 309 309 case 'foreach': 310 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!' )).'):';310 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!','(')).'):'; 311 311 array_push($this->_blockStack,'foreach'); 312 312 break; … … 316 316 break; 317 317 case 'for': 318 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array( )) .'):';318 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array('(')) .'):'; 319 319 array_push($this->_blockStack,'for'); 320 320 break; … … 470 470 } elseif ($inLocale && ($tok=='.' || $tok =='~') ) { 471 471 $locale.=$tok; 472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!')) {472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!' && $tok != '(')) { 473 473 $this->doError2('errors.tpl.tag.character.invalid', $this->_currentTag, $tok); 474 474 } elseif ($tok =='(') { branches/1.0.x/lib/jelix/tpl/jTplCompiler.class.php
r742 r929 4 4 * @subpackage jtpl 5 5 * @author Laurent Jouanneau 6 * @contributor Mathaud Loic ( version standalone), Dominique Papin7 * @copyright 2005-200 7Laurent Jouanneau6 * @contributor Mathaud Loic (standalone version), Dominique Papin 7 * @copyright 2005-2008 Laurent Jouanneau 8 8 * @copyright 2006 Mathaud Loic, 2007 Dominique Papin 9 9 * @link http://www.jelix.org … … 308 308 break; 309 309 case 'foreach': 310 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!' )).'):';310 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!','(')).'):'; 311 311 array_push($this->_blockStack,'foreach'); 312 312 break; … … 316 316 break; 317 317 case 'for': 318 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array( )) .'):';318 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array('(')) .'):'; 319 319 array_push($this->_blockStack,'for'); 320 320 break; … … 470 470 } elseif ($inLocale && ($tok=='.' || $tok =='~') ) { 471 471 $locale.=$tok; 472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!')) {472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!' && $tok != '(')) { 473 473 $this->doError2('errors.tpl.tag.character.invalid', $this->_currentTag, $tok); 474 474 } elseif ($tok =='(') { branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php
r742 r929 87 87 '<p>ok</p>', 88 88 ), 89 89 11=>array( 90 '<p>ok{if $foo} {/if}</p>', 91 '<p>ok<?php if($t->_vars[\'foo\']):?> <?php endif;?></p>', 92 ), 93 12=>array( 94 '<p>ok{if ($foo)} {/if}</p>', 95 '<p>ok<?php if(($t->_vars[\'foo\'])):?> <?php endif;?></p>', 96 ), 97 13=>array( 98 '<p>ok{while ($foo)} {/while}</p>', 99 '<p>ok<?php while(($t->_vars[\'foo\'])):?> <?php endwhile;?></p>', 100 ), 101 14=>array( 102 '<p>ok{while $foo} {/while}</p>', 103 '<p>ok<?php while($t->_vars[\'foo\']):?> <?php endwhile;?></p>', 104 ), 105 15=>array( 106 '<p>ok{jurl ($foo)}</p>', 107 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\']));?></p>', 108 ), 109 16=>array( 110 '<p>ok{jurl ($foo,$params)}</p>', 111 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\'],$t->_vars[\'params\']));?></p>', 112 ), 113 17=>array( 114 '<p>ok{$foo.($truc.$bbb)}</p>', 115 '<p>ok<?php echo $t->_vars[\'foo\'].($t->_vars[\'truc\'].$t->_vars[\'bbb\']); ?></p>', 116 ), 117 18=>array( 118 '<p>ok{if ($foo || $bar) && $baz} {/if}</p>', 119 '<p>ok<?php if(($t->_vars[\'foo\'] || $t->_vars[\'bar\']) && $t->_vars[\'baz\']):?> <?php endif;?></p>', 120 ), 90 121 ); 91 122 92 123 function testCompileContent() { 93 124 $compil = new testJtplContentCompiler(); 125 $compil->outputType = 'html'; 94 126 $compil->trusted = true; 95 127 … … 129 161 function testCompilePlugins() { 130 162 $compil = new testJtplContentCompiler(); 163 $compil->outputType = 'html'; 131 164 $compil->trusted = true; 132 165 … … 141 174 } 142 175 } 143 176 144 177 protected $tplerrors = array( 145 0=>array('{if }',178 0=>array('{if $foo}', 146 179 'jelix~errors.tpl.tag.block.end.missing',array('if',null) ), 147 1=>array('{ifuserconnected} {if } {/if} ',180 1=>array('{ifuserconnected} {if $foo} {/if} ', 148 181 'jelix~errors.tpl.tag.block.end.missing',array('ifuserconnected',null) ), 182 2=>array('{foreach ($t=>$a)} A {/foreach}', 183 'jelix~errors.tpl.tag.character.invalid',array('foreach ($t=>$a)', '(', NULL) ), 184 3=>array('{for ($i=0;$i<$p;$i++)} A {/for}', 185 'jelix~errors.tpl.tag.character.invalid',array('for ($i=0;$i<$p;$i++)','(',null) ), 186 4=>array('{form ($foo,$params)} aa {/form}', 187 'jelix~errors.tplplugin.block.bad.argument.number',array('form','2-6',null) ), 188 5=>array('{($aaa)}', 189 'jelix~errors.tpl.tag.syntax.invalid',array('($aaa)',null) ), 149 190 ); 150 191 151 192 function testCompileErrors() { 152 $compil = new testJtplContentCompiler();153 $compil->trusted = true;154 193 155 194 foreach($this->tplerrors as $k=>$t){ 195 $compil = new testJtplContentCompiler(); 196 $compil->outputType = 'html'; 197 $compil->trusted = true; 156 198 try{ 157 199 $compil->compileContent2($t[0]); 158 200 $this->fail("Test '$k', exception didn't happen"); 159 201 }catch(jException $e){ 160 $this->assertEqual($e->getLocaleKey(), $t[1] );161 $this->assertEqualOrDiff($e->getLocaleParameters(), $t[2] );202 $this->assertEqual($e->getLocaleKey(), $t[1], "Test '$k': %s (local parameters: ".var_export($e->getLocaleParameters(), true).")"); 203 $this->assertEqualOrDiff($e->getLocaleParameters(), $t[2], "Test '$k': %s"); 162 204 }catch(Exception $e){ 163 205 $this->fail("Test '$k', Unknown Exception: ".$e->getMessage()); branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php
r742 r929 87 87 '<p>ok</p>', 88 88 ), 89 89 11=>array( 90 '<p>ok{if $foo} {/if}</p>', 91 '<p>ok<?php if($t->_vars[\'foo\']):?> <?php endif;?></p>', 92 ), 93 12=>array( 94 '<p>ok{if ($foo)} {/if}</p>', 95 '<p>ok<?php if(($t->_vars[\'foo\'])):?> <?php endif;?></p>', 96 ), 97 13=>array( 98 '<p>ok{while ($foo)} {/while}</p>', 99 '<p>ok<?php while(($t->_vars[\'foo\'])):?> <?php endwhile;?></p>', 100 ), 101 14=>array( 102 '<p>ok{while $foo} {/while}</p>', 103 '<p>ok<?php while($t->_vars[\'foo\']):?> <?php endwhile;?></p>', 104 ), 105 15=>array( 106 '<p>ok{jurl ($foo)}</p>', 107 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\']));?></p>', 108 ), 109 16=>array( 110 '<p>ok{jurl ($foo,$params)}</p>', 111 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\'],$t->_vars[\'params\']));?></p>', 112 ), 113 17=>array( 114 '<p>ok{$foo.($truc.$bbb)}</p>', 115 '<p>ok<?php echo $t->_vars[\'foo\'].($t->_vars[\'truc\'].$t->_vars[\'bbb\']); ?></p>', 116 ), 117 18=>array( 118 '<p>ok{if ($foo || $bar) && $baz} {/if}</p>', 119 '<p>ok<?php if(($t->_vars[\'foo\'] || $t->_vars[\'bar\']) && $t->_vars[\'baz\']):?> <?php endif;?></p>', 120 ), 90 121 ); 91 122 92 123 function testCompileContent() { 93 124 $compil = new testJtplContentCompiler(); 125 $compil->outputType = 'html'; 94 126 $compil->trusted = true; 95 127 … … 129 161 function testCompilePlugins() { 130 162 $compil = new testJtplContentCompiler(); 163 $compil->outputType = 'html'; 131 164 $compil->trusted = true; 132 165 … … 141 174 } 142 175 } 143 176 144 177 protected $tplerrors = array( 145 0=>array('{if }',178 0=>array('{if $foo}', 146 179 'jelix~errors.tpl.tag.block.end.missing',array('if',null) ), 147 1=>array('{ifuserconnected} {if } {/if} ',180 1=>array('{ifuserconnected} {if $foo} {/if} ', 148 181 'jelix~errors.tpl.tag.block.end.missing',array('ifuserconnected',null) ), 182 2=>array('{foreach ($t=>$a)} A {/foreach}', 183 'jelix~errors.tpl.tag.character.invalid',array('foreach ($t=>$a)', '(', NULL) ), 184 3=>array('{for ($i=0;$i<$p;$i++)} A {/for}', 185 'jelix~errors.tpl.tag.character.invalid',array('for ($i=0;$i<$p;$i++)','(',null) ), 186 4=>array('{form ($foo,$params)} aa {/form}', 187 'jelix~errors.tplplugin.block.bad.argument.number',array('form','2-6',null) ), 188 5=>array('{($aaa)}', 189 'jelix~errors.tpl.tag.syntax.invalid',array('($aaa)',null) ), 149 190 ); 150 191 151 192 function testCompileErrors() { 152 $compil = new testJtplContentCompiler();153 $compil->trusted = true;154 193 155 194 foreach($this->tplerrors as $k=>$t){ 195 $compil = new testJtplContentCompiler(); 196 $compil->outputType = 'html'; 197 $compil->trusted = true; 156 198 try{ 157 199 $compil->compileContent2($t[0]); 158 200 $this->fail("Test '$k', exception didn't happen"); 159 201 }catch(jException $e){ 160 $this->assertEqual($e->getLocaleKey(), $t[1] );161 $this->assertEqualOrDiff($e->getLocaleParameters(), $t[2] );202 $this->assertEqual($e->getLocaleKey(), $t[1], "Test '$k': %s (local parameters: ".var_export($e->getLocaleParameters(), true).")"); 203 $this->assertEqualOrDiff($e->getLocaleParameters(), $t[2], "Test '$k': %s"); 162 204 }catch(Exception $e){ 163 205 $this->fail("Test '$k', Unknown Exception: ".$e->getMessage()); branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php
r742 r929 87 87 '<p>ok</p>', 88 88 ), 89 89 11=>array( 90 '<p>ok{if $foo} {/if}</p>', 91 '<p>ok<?php if($t->_vars[\'foo\']):?> <?php endif;?></p>', 92 ), 93 12=>array( 94 '<p>ok{if ($foo)} {/if}</p>', 95 '<p>ok<?php if(($t->_vars[\'foo\'])):?> <?php endif;?></p>', 96 ), 97 13=>array( 98 '<p>ok{while ($foo)} {/while}</p>', 99 '<p>ok<?php while(($t->_vars[\'foo\'])):?> <?php endwhile;?></p>', 100 ), 101 14=>array( 102 '<p>ok{while $foo} {/while}</p>', 103 '<p>ok<?php while($t->_vars[\'foo\']):?> <?php endwhile;?></p>', 104 ), 105 15=>array( 106 '<p>ok{jurl ($foo)}</p>', 107 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\']));?></p>', 108 ), 109 16=>array( 110 '<p>ok{jurl ($foo,$params)}</p>', 111 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\'],$t->_vars[\'params\']));?></p>', 112 ), 113 17=>array( 114 '<p>ok{$foo.($truc.$bbb)}</p>', 115 '<p>ok<?php echo $t->_vars[\'foo\'].($t->_vars[\'truc\'].$t->_vars[\'bbb\']); ?></p>', 116 ), 117 18=>array( 118 '<p>ok{if ($foo || $bar) && $baz} {/if}</p>', 119 '<p>ok<?php if(($t->_vars[\'foo\'] || $t->_vars[\'bar\']) && $t->_vars[\'baz\']):?> <?php endif;?></p>', 120 ), 90 121 ); 91 122 92 123 function testCompileContent() { 93 124 $compil = new testJtplContentCompiler(); 125 $compil->outputType = 'html'; 94 126 $compil->trusted = true; 95 127 … … 129 161 function testCompilePlugins() { 130 162 $compil = new testJtplContentCompiler(); 163 $compil->outputType = 'html'; 131 164 $compil->trusted = true; 132 165 … … 141 174 } 142 175 } 143 176 144 177 protected $tplerrors = array( 145 0=>array('{if }',178 0=>array('{if $foo}', 146 179 'jelix~errors.tpl.tag.block.end.missing',array('if',null) ), 147 1=>array('{ifuserconnected} {if } {/if} ',180 1=>array('{ifuserconnected} {if $foo} {/if} ', 148 181 'jelix~errors.tpl.tag.block.end.missing',array('ifuserconnected',null) ), 182 2=>array('{foreach ($t=>$a)} A {/foreach}', 183 'jelix~errors.tpl.tag.character.invalid',array('foreach ($t=>$a)', '(', NULL) ), 184 3=>array('{for ($i=0;$i<$p;$i++)} A {/for}', 185 'jelix~errors.tpl.tag.character.invalid',array('for ($i=0;$i<$p;$i++)','(',null) ), 186 4=>array('{form ($foo,$params)} aa {/form}', 187 'jelix~errors.tplplugin.block.bad.argument.number',array('form','2-6',null) ), 188 5=>array('{($aaa)}', 189 'jelix~errors.tpl.tag.syntax.invalid',array('($aaa)',null) ), 149 190 ); 150 191 151 192 function testCompileErrors() { 152 $compil = new testJtplContentCompiler();153 $compil->trusted = true;154 193 155 194 foreach($this->tplerrors as $k=>$t){ 195 $compil = new testJtplContentCompiler(); 196 $compil->outputType = 'html'; 197 $compil->trusted = true; 156 198 try{ 157 199 $compil->compileContent2($t[0]); 158 200 $this->fail("Test '$k', exception didn't happen"); 159 201 }catch(jException $e){ 160 $this->assertEqual($e->getLocaleKey(), $t[1] );161 $this->assertEqualOrDiff($e->getLocaleParameters(), $t[2] );202 $this->assertEqual($e->getLocaleKey(), $t[1], "Test '$k': %s (local parameters: ".var_export($e->getLocaleParameters(), true).")"); 203 $this->assertEqualOrDiff($e->getLocaleParameters(), $t[2], "Test '$k': %s"); 162 204 }catch(Exception $e){ 163 205 $this->fail("Test '$k', Unknown Exception: ".$e->getMessage()); branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php
r742 r929 87 87 '<p>ok</p>', 88 88 ), 89 89 11=>array( 90 '<p>ok{if $foo} {/if}</p>', 91 '<p>ok<?php if($t->_vars[\'foo\']):?> <?php endif;?></p>', 92 ), 93 12=>array( 94 '<p>ok{if ($foo)} {/if}</p>', 95 '<p>ok<?php if(($t->_vars[\'foo\'])):?> <?php endif;?></p>', 96 ), 97 13=>array( 98 '<p>ok{while ($foo)} {/while}</p>', 99 '<p>ok<?php while(($t->_vars[\'foo\'])):?> <?php endwhile;?></p>', 100 ), 101 14=>array( 102 '<p>ok{while $foo} {/while}</p>', 103 '<p>ok<?php while($t->_vars[\'foo\']):?> <?php endwhile;?></p>', 104 ), 105 15=>array( 106 '<p>ok{jurl ($foo)}</p>', 107 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\']));?></p>', 108 ), 109 16=>array( 110 '<p>ok{jurl ($foo,$params)}</p>', 111 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\'],$t->_vars[\'params\']));?></p>', 112 ), 113 17=>array( 114 '<p>ok{$foo.($truc.$bbb)}</p>', 115 '<p>ok<?php echo $t->_vars[\'foo\'].($t->_vars[\'truc\'].$t->_vars[\'bbb\']); ?></p>', 116 ), 117 18=>array( 118 '<p>ok{if ($foo || $bar) && $baz} {/if}</p>', 119 '<p>ok<?php if(($t->_vars[\'foo\'] || $t->_vars[\'bar\']) && $t->_vars[\'baz\']):?> <?php endif;?></p>', 120 ), 90 121 ); 91 122 92 123 function testCompileContent() { 93 124 $compil = new testJtplContentCompiler(); 125 $compil->outputType = 'html'; 94 126 $compil->trusted = true; 95 127 … … 129 161 function testCompilePlugins() { 130 162 $compil = new testJtplContentCompiler(); 163 $compil->outputType = 'html'; 131 164 $compil->trusted = true; 132 165 … … 141 174 } 142 175 } 143 176 144 177 protected $tplerrors = array( 145 0=>array('{if }',178 0=>array('{if $foo}', 146 179 'jelix~errors.tpl.tag.block.end.missing',array('if',null) ), 147 1=>array('{ifuserconnected} {if } {/if} ',180 1=>array('{ifuserconnected} {if $foo} {/if} ', 148 181 'jelix~errors.tpl.tag.block.end.missing',array('ifuserconnected',null) ), 182 2=>array('{foreach ($t=>$a)} A {/foreach}', 183 'jelix~errors.tpl.tag.character.invalid',array('foreach ($t=>$a)', '(', NULL) ), 184 3=>array('{for ($i=0;$i<$p;$i++)} A {/for}', 185 'jelix~errors.tpl.tag.character.invalid',array('for ($i=0;$i<$p;$i++)','(',null) ), 186 4=>array('{form ($foo,$params)} aa {/form}', 187 'jelix~errors.tplplugin.block.bad.argument.number',array('form','2-6',null) ), 188 5=>array('{($aaa)}', 189 'jelix~errors.tpl.tag.syntax.invalid',array('($aaa)',null) ), 149 190 ); 150 191 151 192 function testCompileErrors() { 152 $compil = new testJtplContentCompiler();153 $compil->trusted = true;154 193 155 194 foreach($this->tplerrors as $k=>$t){ 195 $compil = new testJtplContentCompiler(); 196 $compil->outputType = 'html'; 197 $compil->trusted = true; 156 198 try{ 157 199 $compil->compileContent2($t[0]); 158 200 $this->fail("Test '$k', exception didn't happen"); 159 201 }catch(jException $e){ 160 $this->assertEqual($e->getLocaleKey(), $t[1] );161 $this->assertEqualOrDiff($e->getLocaleParameters(), $t[2] );202 $this->assertEqual($e->getLocaleKey(), $t[1], "Test '$k': %s (local parameters: ".var_export($e->getLocaleParameters(), true).")"); 203 $this->assertEqualOrDiff($e->getLocaleParameters(), $t[2], "Test '$k': %s"); 162 204 }catch(Exception $e){ 163 205 $this->fail("Test '$k', Unknown Exception: ".$e->getMessage()); branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php
r571 r929 162 162 '@@'=>array('jelix~errors.tpl.tag.locale.invalid',array('','')), 163 163 '[$aa/234]'=>array('jelix~errors.tpl.tag.character.invalid',array('','[','')), 164 '($aa/234)'=>array('jelix~errors.tpl.tag.character.invalid',array('','(','')),165 164 '$b+($aa/234'=>array('jelix~errors.tpl.tag.bracket.error',array('','')), 166 165 '$b+(($aa/234)'=>array('jelix~errors.tpl.tag.bracket.error',array('','')), branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php
r571 r929 162 162 '@@'=>array('jelix~errors.tpl.tag.locale.invalid',array('','')), 163 163 '[$aa/234]'=>array('jelix~errors.tpl.tag.character.invalid',array('','[','')), 164 '($aa/234)'=>array('jelix~errors.tpl.tag.character.invalid',array('','(','')),165 164 '$b+($aa/234'=>array('jelix~errors.tpl.tag.bracket.error',array('','')), 166 165 '$b+(($aa/234)'=>array('jelix~errors.tpl.tag.bracket.error',array('','')), branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php
r571 r929 162 162 '@@'=>array('jelix~errors.tpl.tag.locale.invalid',array('','')), 163 163 '[$aa/234]'=>array('jelix~errors.tpl.tag.character.invalid',array('','[','')), 164 '($aa/234)'=>array('jelix~errors.tpl.tag.character.invalid',array('','(','')),165 164 '$b+($aa/234'=>array('jelix~errors.tpl.tag.bracket.error',array('','')), 166 165 '$b+(($aa/234)'=>array('jelix~errors.tpl.tag.bracket.error',array('','')), branches/1.0.x/testapp/modules/jelix_tests/tests/jtpl.expressions_parsing.html_cli.php
r571 r929 162 162 '@@'=>array('jelix~errors.tpl.tag.locale.invalid',array('','')), 163 163 '[$aa/234]'=>array('jelix~errors.tpl.tag.character.invalid',array('','[','')), 164 '($aa/234)'=>array('jelix~errors.tpl.tag.character.invalid',array('','(','')),165 164 '$b+($aa/234'=>array('jelix~errors.tpl.tag.bracket.error',array('','')), 166 165 '$b+(($aa/234)'=>array('jelix~errors.tpl.tag.bracket.error',array('','')), trunk/lib/jelix/tpl/jTplCompiler.class.php
r892 r929 4 4 * @subpackage jtpl 5 5 * @author Laurent Jouanneau 6 * @contributor Mathaud Loic ( version standalone), Dominique Papin7 * @copyright 2005-200 7Laurent Jouanneau6 * @contributor Mathaud Loic (standalone version), Dominique Papin 7 * @copyright 2005-2008 Laurent Jouanneau 8 8 * @copyright 2006 Mathaud Loic, 2007 Dominique Papin 9 9 * @link http://www.jelix.org … … 306 306 break; 307 307 case 'foreach': 308 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!' )).'):';308 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!','(')).'):'; 309 309 array_push($this->_blockStack,'foreach'); 310 310 break; … … 314 314 break; 315 315 case 'for': 316 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array( )) .'):';316 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array('(')) .'):'; 317 317 array_push($this->_blockStack,'for'); 318 318 break; … … 470 470 } elseif ($inLocale && ($tok=='.' || $tok =='~') ) { 471 471 $locale.=$tok; 472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!')) {472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!' && $tok != '(')) { 473 473 $this->doError2('errors.tpl.tag.character.invalid', $this->_currentTag, $tok); 474 474 } elseif ($tok =='(') { trunk/lib/jelix/tpl/jTplCompiler.class.php
r892 r929 4 4 * @subpackage jtpl 5 5 * @author Laurent Jouanneau 6 * @contributor Mathaud Loic ( version standalone), Dominique Papin7 * @copyright 2005-200 7Laurent Jouanneau6 * @contributor Mathaud Loic (standalone version), Dominique Papin 7 * @copyright 2005-2008 Laurent Jouanneau 8 8 * @copyright 2006 Mathaud Loic, 2007 Dominique Papin 9 9 * @link http://www.jelix.org … … 306 306 break; 307 307 case 'foreach': 308 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!' )).'):';308 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!','(')).'):'; 309 309 array_push($this->_blockStack,'foreach'); 310 310 break; … … 314 314 break; 315 315 case 'for': 316 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array( )) .'):';316 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array('(')) .'):'; 317 317 array_push($this->_blockStack,'for'); 318 318 break; … … 470 470 } elseif ($inLocale && ($tok=='.' || $tok =='~') ) { 471 471 $locale.=$tok; 472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!')) {472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!' && $tok != '(')) { 473 473 $this->doError2('errors.tpl.tag.character.invalid', $this->_currentTag, $tok); 474 474 } elseif ($tok =='(') { trunk/lib/jelix/tpl/jTplCompiler.class.php
r892 r929 4 4 * @subpackage jtpl 5 5 * @author Laurent Jouanneau 6 * @contributor Mathaud Loic ( version standalone), Dominique Papin7 * @copyright 2005-200 7Laurent Jouanneau6 * @contributor Mathaud Loic (standalone version), Dominique Papin 7 * @copyright 2005-2008 Laurent Jouanneau 8 8 * @copyright 2006 Mathaud Loic, 2007 Dominique Papin 9 9 * @link http://www.jelix.org … … 306 306 break; 307 307 case 'foreach': 308 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!' )).'):';308 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!','(')).'):'; 309 309 array_push($this->_blockStack,'foreach'); 310 310 break; … … 314 314 break; 315 315 case 'for': 316 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array( )) .'):';316 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array('(')) .'):'; 317 317 array_push($this->_blockStack,'for'); 318 318 break; … … 470 470 } elseif ($inLocale && ($tok=='.' || $tok =='~') ) { 471 471 $locale.=$tok; 472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!')) {472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!' && $tok != '(')) { 473 473 $this->doError2('errors.tpl.tag.character.invalid', $this->_currentTag, $tok); 474 474 } elseif ($tok =='(') { trunk/lib/jelix/tpl/jTplCompiler.class.php
r892 r929 4 4 * @subpackage jtpl 5 5 * @author Laurent Jouanneau 6 * @contributor Mathaud Loic ( version standalone), Dominique Papin7 * @copyright 2005-200 7Laurent Jouanneau6 * @contributor Mathaud Loic (standalone version), Dominique Papin 7 * @copyright 2005-2008 Laurent Jouanneau 8 8 * @copyright 2006 Mathaud Loic, 2007 Dominique Papin 9 9 * @link http://www.jelix.org … … 306 306 break; 307 307 case 'foreach': 308 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!' )).'):';308 $res = 'foreach('.$this->_parseFinal($args,$this->_allowedInForeach, array(';','!','(')).'):'; 309 309 array_push($this->_blockStack,'foreach'); 310 310 break; … … 314 314 break; 315 315 case 'for': 316 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array( )) .'):';316 $res = 'for('. $this->_parseFinal($args, $this->_allowedInExpr, array('(')) .'):'; 317 317 array_push($this->_blockStack,'for'); 318 318 break; … … 470 470 } elseif ($inLocale && ($tok=='.' || $tok =='~') ) { 471 471 $locale.=$tok; 472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!')) {472 } elseif ($inLocale || in_array($tok,$exceptchar) || ($first && $tok != '!' && $tok != '(')) { 473 473 $this->doError2('errors.tpl.tag.character.invalid', $this->_currentTag, $tok); 474 474 } elseif ($tok =='(') { trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php
r815 r929 87 87 '<p>ok</p>', 88 88 ), 89 89 11=>array( 90 '<p>ok{if $foo} {/if}</p>', 91 '<p>ok<?php if($t->_vars[\'foo\']):?> <?php endif;?></p>', 92 ), 93 12=>array( 94 '<p>ok{if ($foo)} {/if}</p>', 95 '<p>ok<?php if(($t->_vars[\'foo\'])):?> <?php endif;?></p>', 96 ), 97 13=>array( 98 '<p>ok{while ($foo)} {/while}</p>', 99 '<p>ok<?php while(($t->_vars[\'foo\'])):?> <?php endwhile;?></p>', 100 ), 101 14=>array( 102 '<p>ok{while $foo} {/while}</p>', 103 '<p>ok<?php while($t->_vars[\'foo\']):?> <?php endwhile;?></p>', 104 ), 105 15=>array( 106 '<p>ok{jurl ($foo)}</p>', 107 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\']));?></p>', 108 ), 109 16=>array( 110 '<p>ok{jurl ($foo,$params)}</p>', 111 '<p>ok<?php jtpl_function_html_jurl( $t,($t->_vars[\'foo\'],$t->_vars[\'params\']));?></p>', 112 ), 113 17=>array( 114 '<p>ok{$foo.($truc.$bbb)}</p>', 115 '<p>ok<?php echo $t->_vars[\'foo\'].($t->_vars[\'truc\'].$t->_vars[\'bbb\']); ?></p>', 116 ), 117 18=>array( 118 '<p>ok{if ($foo || $bar) && $baz} {/if}</p>', 119 '<p>ok<?php if(($t->_vars[\'foo\'] || $t->_vars[\'bar\']) && $t->_vars[\'baz\']):?> <?php endif;?></p>', 120 ), 90 121 ); 91 122 92 123 function testCompileContent() { 93 124 $compil = new testJtplContentCompiler(); 125 $compil->outputType = 'html'; 94 126 $compil->trusted = true; 95 127 … … 143 175 function testCompilePlugins() { 144 176 $compil = new testJtplContentCompiler(); 177 $compil->outputType = 'html'; 145 178 $compil->trusted = true; 146 179 … … 157 190 158 191 protected $tplerrors = array( 159 0=>array('{if }',192 0=>array('{if $foo}', 160 193 'jelix~errors.tpl.tag.block.end.missing',array('if',null) ), 161 1=>array('{ifuserconnected} {if } {/if} ',194 1=>array('{ifuserconnected} {if $foo} {/if} ', 162 195 &
