Wrapping list elements with single quotes in cfml

Published: {ts '2015-04-28 00:00:00'}
Author: Steven Neiland
Site Url: http://www.neiland.net/article/wrapping-list-elements-with-single-quotes-in-cfml/

A few weeks ago I needed to modify a list to wrap each list element with single quotes. Normally you would do this when outputting the data in a view but in this case that was not an option.

I was about to write a function to to this when I decided to take a chance that someone had already written this for me. A quick google later and I discovered that ColdFusion has a builtin function for exactly this purpose named "listQualify()".

Example

unqualifiedList = "dog,cat,bird,pig"; qualifiedList = listQualify(unqualifiedList, "'");
unqualifiedList: dog,cat,bird,pig
qualifiedList: 'dog','cat','bird','pig'

It seems even after all these years I am still learning new things about cfml.