|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
tdieden Smarty n00b
Joined: 07 Jan 2004 Posts: 1
|
Posted: Wed Jan 07, 2004 10:40 pm Post subject: error in Smarty_Compiler::_parse_is_expr() 2.6.0 and older |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Jan 07, 2004 10:51 pm Post subject: |
|
|
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 |
|
|
|
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
|