CFLib.org – Common Function Library Project

paragraphtolist(text)

Last updated May 10, 2005

author

Tony Monast

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 "";
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson