Another option is to use css and use a formula field to toggle your styling. This keeps your logic out of code and in data, which I find scales better. The general concept is to use merge text in your template field to insert a style value or dynamic class.
It could look like:
{{Display_Value}}
or:
{{Display_Value}}
In the first example your formula would need to reference a css class definition and in the second example it would need to output a color value.
There are some examples here:
https://community.skuid.com/t/css-for-template-fields
and here: