diff --git a/Smarty.class.php b/Smarty.class.php index c88b203b..ef5e3540 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -710,9 +710,14 @@ class Smarty $expr = "($is_arg % 2)"; break; - case 'mod': - $expr_arg = $tokens[$expr_end++]; - $expr = "!($is_arg % $expr_arg)"; + case 'div': + if ($tokens[$expr_end] == 'by') { + $expr_end++; + $expr_arg = $tokens[$expr_end++]; + $expr = "!($is_arg % $expr_arg)"; + } else { + /* TODO syntax error: expecting 'by' */ + } break; default: diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl index 0ed2e099..6bfbbc71 100644 --- a/demo/templates/index.tpl +++ b/demo/templates/index.tpl @@ -11,9 +11,9 @@ hello, my name is {$Name|upper} My interests are: {section name=outer loop=$FirstName} {if %outer.index% is odd by 2} - . {$outer/FirstName} {$outer/LastName} + {%outer.rownum%} . {$outer/FirstName} {$outer/LastName} {else} - * {$outer/FirstName} {$outer/LastName} + {%outer.rownum%} * {$outer/FirstName} {$outer/LastName} {/if} {sectionelse} none diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index c88b203b..ef5e3540 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -710,9 +710,14 @@ class Smarty $expr = "($is_arg % 2)"; break; - case 'mod': - $expr_arg = $tokens[$expr_end++]; - $expr = "!($is_arg % $expr_arg)"; + case 'div': + if ($tokens[$expr_end] == 'by') { + $expr_end++; + $expr_arg = $tokens[$expr_end++]; + $expr = "!($is_arg % $expr_arg)"; + } else { + /* TODO syntax error: expecting 'by' */ + } break; default: diff --git a/templates/index.tpl b/templates/index.tpl index 0ed2e099..6bfbbc71 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -11,9 +11,9 @@ hello, my name is {$Name|upper} My interests are: {section name=outer loop=$FirstName} {if %outer.index% is odd by 2} - . {$outer/FirstName} {$outer/LastName} + {%outer.rownum%} . {$outer/FirstName} {$outer/LastName} {else} - * {$outer/FirstName} {$outer/LastName} + {%outer.rownum%} * {$outer/FirstName} {$outer/LastName} {/if} {sectionelse} none