I have a template that returns the friendly name of a number of entities based on their state (in this cases persons at home). This returns anywhere from zero to 4 results. I want to output this information to a dashboard, but I cannot figure out how to properly format the information. What I am looking for is the ability to do proper sentencing format, i.e. if only one result i want to just output “x”, if two results are returned I want to print “x and y”, if three results are provided I want to output “x, y and z” etc.
Am I missing something completely obvious for doing this, or is this as complicated as I have made it in my mind?