Quote:
Originally Posted by Penny_Dreadful
I edited the code a bit so I could use the default rating column and change the colour for each number of stars.
Code:
program:
r = $rating;
if r >=#5 then '#2EAB64'
elif r >=#4 then '#94E4C9'
elif r >=#3 then '#FE657D'
elif r >=#2 then '#FCB2A9'
elif r >=#1 then '#FEDC78'
fi
|
FWIW: this template will have better performance because the sequence of comparisons is done in python instead of the template interpreter.
Code:
program:
first_matching_cmp(
$rating,
1.1, '#FEDC78',
2.1, '#94E4C9',
3.1, '#FE657D',
4.1, '#94E4C9',
'#2EAB64')
I used 1.1 instead of 1 etc. because the comparisons are 'less than'. I should have made it <= when I added first_matching_cmp() to the template language. Oh well, too late now.