[Templates] Alternative to IF / ELSE's ?
Leo Lapworth
Leo Lapworth <leo@cuckoo.org>
Thu, 14 Nov 2002 11:29:58 +0000
Hi All,
I have a price and need to know which of 8
ranges it's in.
e.g.
0 -> 200,000
200,000 -> 300,000
300,000 -> 400,000
...
2,000,000 +
so I could do
[% IF price < 200000 %]
[% price_from = 0 %]
[% price_to = 200000 %]
[% ELSIF price < 300000 %]
[% price_from = 200000 %]
[% price_to = 300000 %]
....
[% ELSE %]
[% price_from = 2000000 %]
[% price_to = 999999999 %]
[% END %]
But..
a) it's seems a lot of code for something simple
b) I have to have a different set of ranges if it's a
different price type.
My main concern is speed (this will be processed a lot),
I could extract it from the template (and put it in the perl)
but it's more design logic - the price_from and price_to
are then used to create a link to another page and the
values could change but the HTML person should be
responsible for this rather than the perl guys.
Anyway, and ideas would be appreciated, maybe IF / ELSE
is the best way.
Cheers
Leo