Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

error in Smarty_Compiler::_parse_is_expr() 2.6.0 and older

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
tdieden
Smarty n00b


Joined: 07 Jan 2004
Posts: 1

PostPosted: Wed Jan 07, 2004 10:40 pm    Post subject: error in Smarty_Compiler::_parse_is_expr() 2.6.0 and older Reply with quote

Hello list,

If using an expression like:

script:
$test = array(0=>array( ... ), 1 => array(), ... )

template:
{foreach from=$test item=val key=loop}
{if $loop is odd}
....
{/if}
{/foreach}

smarty returns an error because the offest ($expr_end) of $tokens is empty. I have changed the code (line 1358 - 1384):

case 'even':
if (empty($expr_end)) {

$expr = "!($is_arg % 2)";

} elseif (@$tokens[$expr_end] == 'by') {

$expr_end++;
$expr_arg = $tokens[$expr_end++];
$expr = "!(($is_arg / $expr_arg) % " . $this->_parse_var_props($expr_arg) . ")";

}
break;

case 'odd':
if (empty($expr_end)) {

$expr = "($is_arg % 2)";

} elseif (@$tokens[$expr_end] == 'by') {

$expr_end++;
$expr_arg = $tokens[$expr_end++];
$expr = "(($is_arg / $expr_arg) % ". $this->_parse_var_props($expr_arg) . ")";

}
break;

Regards, Tom
Back to top
View user's profile Send private message Send e-mail
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Jan 07, 2004 10:51 pm    Post subject: Reply with quote

i cannot reproduce any problems with "{if $loop is odd} ... {/if}".

what error-message is printed (what kind of error occurs)?

did you try the cvs-version? "odd" and "even" have been touched there for other reasons.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP