else should not take any arguments

From: Date: Tue, 16 Oct 2007 10:14:25 +0000
Subject: else should not take any arguments
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-3053@lists.php.net to get a copy of this message
Hi guys, Several days ago I just had a problem with elseif statement, as it is specified in documentation these is not any tag called "else if" but I used that tag and it just executed the else statement and ignored the if itself. for example: {assign var="test" value="blah"} {if $test != 'blah'} Dummy {elseif $test == 'str'} Blah Blah {/if} {if $test != 'blah'} Dummy2 {else if $test == 'str'} Blah2 Blah2 {/if} which expected output is blank page but it shows "Blah2 Blah2". Yes this is not smarty bug but it is template designer mistake. IMHO it is nice to throw an error in such cases then template designer can correct the mistake. another example of this situation is: {if 'blah' != 'blah'} Dummy2 {else asdasdasdasdasd asd asdasda} Blah Blah {/if} as you can saw else ignores any arguments. I come here with a tiny patch for this situation, it is attached with this email, hope it could be usefull. Best Regards, Armen

Attachment: [text/x-patch] elseif.patch
« previous php.smarty.dev (#3053) next »