Microsoft#Microsoft disabled all this in versions 2016 and later, it still works in older SP version and non-Modern Experiences
**Original answer:**
If you don't mind:
- Always obeying the Microsoft SharePoint 2013 way of doing things
- writing a separate JavaScript file
- Uploading it somewhere in SharePoint
- Creating a JSlink connection everywhere you want to execute it
- or messing around with extra webparts
then CSR is the best option
If you:
- Are not afraid to use something that has worked since 2010 (and works in SP2010)
- do not want to create separate files for display logic
- want a solution that works no matter where a View Column is displayed
- want a solution that can be wrapped in a List Template
- works even if there are multiple Views of the same List on One page
Then you could add the JavaScript logic to a Calculated Column.
Set the datatype to Number and it will evaluate your HTML/JavaScript
Create a Calculated Column "ColorStatus" Paste the Formula:
=[Status]
"<img src=""/_layouts/images/blank.gif"" "
&" onload=""{"
&" this.parentNode.parentNode.parentNode.style.backgroundColor="
&" ({"
&" 'Not Started':'#FFF1AD',"
&" 'Draft':'pink',"
&" 'Reviewed':'lightgreen',"
&" 'Scheduled':'lightcoral',"
&" 'Published':'none',"
&" 'Final':'limegreen',"
&" 'Expired':'indianred'"
&" })['"&[Status]&"']"
&" }"">"
And set the Datatype to number.
Add to Default View
Do not add to Content Types (or the Formula will show up as text on Forms) this works in Views only!!
Detail descscription on How it works at: http://www.viewmaster365.com/#/How
Of course there are drawbacks;
biggest one is that the HTML/Javascript contents shows up as text in Alert messages
The fun part is you can use all you SharePoint Formula skills on the &[Status]& part to get any result you want.