Skip to content

Instantly share code, notes, and snippets.

@roryl
Last active April 11, 2016 12:30
Show Gist options
  • Save roryl/2433bba8846d72eabda7db04ad4147a0 to your computer and use it in GitHub Desktop.
Save roryl/2433bba8846d72eabda7db04ad4147a0 to your computer and use it in GitHub Desktop.
Lucee List Examples
<cfscript>
myList = "one,two,three"; //Create a comma separated list
echo(myList.listLen() & "<br />"); //echo the length, should be 3
myOtherList = "one|two|three"; //Create a pipe separated list
echo(myOtherList.listLen("|") & "<br />"); //Echo the length, should be three. Pass the delimiter because we are overriding the default which was a comma
echo(myList.listLen("t")); //Any character can be a delimiter
</cfscript>
<cfscript>
myList = "one,two,three";
for(val in myList){
echo(val & "<br />");
}
</cfscript>
<cfscript>
myList = "one|two|three";
for(val in myList.listChangeDelims("," , "|")){
echo(val & "<br />");
}
</cfscript>
<cfscript>
myList = "one,two,three";
myArray = myList.listToArray();
for(val in myArray){
echo(val & "<br />");
}
</cfscript>
/**
* My xUnit Test
*/
component extends="testbox.system.BaseSpec"{
/*********************************** LIFE CYCLE Methods ***********************************/
// executes before all test cases
function beforeTests(){
}
// executes after all test cases
function afterTests(){
}
// executes before every test case
function setup( currentMethod ){
}
// executes after every test case
function teardown( currentMethod ){
}
/*********************************** TEST CASES BELOW ***********************************/
// Remember that test cases MUST start or end with the keyword 'test'
function checkAllSyntaxTest(){
var files = directoryList("");
for(file IN files){
if(file CONTAINS ".cfm"){
include template="#getFileFromPath(file)#";
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment