[Templates] reiteration question, by increments of something
other than 1
Andy Wardley
abw@wardley.org
Thu, 27 Jul 2006 10:15:42 +0100
Me wrote:
> FOREACH y = [0..40]
>
> --> but I want to increment by 3
There's no built-in support for it in TT2, but you can achieve the
desired effect with something like this:
[% FOREACH x IN [0..13]; y = x * 3 %]
The improvements in the parser for TT3 means that we'll be able to
support a more diverse grammar, allowing you to write this:
[% FOREACH y FROM 0 TO 40 STEP 3 %]
Without digressing into a long technical discussion, the architecture of
the TT2 parser makes it hard, if not impossible, to change the TT2
language, even in minor ways like this. (Actually, it's not that you
can't change it, but it's the knock-on effects that changes tend to
have. Global keywords and all that. But I digress....) So that's why
we've got a brand new parser for TT3 which makes these problems go away.
HTH
A