paragraphtolist(text)
Last updated May 10, 2005
Version: 1 | Requires: CF5 | Library: StrLib
Description:
Take a text and use the carriage return as a delimiter list to generate an html list (<ul>). Each line become an element of the list (<li>).
Return Values:
Returns a string.
Example:
<cfsavecontent variable="text">
Line 1
Line 2
Line 3
</cfsavecontent>
<cfoutput>#paragraphToList(text)#</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
text | Text to format. | Yes |
Full UDF Source:
/**
* Convert a text with many lines into a html list.
*
* @param text Text to format. (Required)
* @return Returns a string.
* @author Tony Monast (merkel_@hotmail.com)
* @version 1, May 10, 2005
*/
function paragraphToList(text) {
var thelist = "";
var i = 1;
text = trim(text);
for(i=1; i lte listLen(text,chr(13));i=i+1) thelist = thelist & "<li>" & ListGetAt(text,i,chr(13)) & "</li>";
if(len(thelist) GT 0) {
thelist = "<ul>" & thelist & "</ul>";
return thelist ;
} else return "";
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016