View Single Post
Old 01-19-2022, 06:32 PM   #18
Penny_Dreadful
She/Her
Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.Penny_Dreadful is my North, my South, my East and West.
 
Penny_Dreadful's Avatar
 
Posts: 87
Karma: 142774
Join Date: Aug 2009
Location: Perth, Australia
Device: Kindle PW5 (G001PX) PW3 PW1
Quote:
Originally Posted by chaley View Post
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.

Thanks Chaley, this is fantastic 💚
Penny_Dreadful is offline   Reply With Quote