Last active
March 11, 2016 10:46
-
-
Save roryl/708a488afcf4a86f1931 to your computer and use it in GitHub Desktop.
Lucee Template Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>About Us</h1> | |
<cfinclude template="navigation.cfm" /> | |
<p> | |
Page content about us | |
</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
<div> | |
#now()# | |
</div> | |
</cfoutput> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- Setup an in memory database object ----> | |
<cfset myCars = queryNew("carModel","varchar",[{carModel:"Explorer"},{carModel:"Camaro"},{carModel:"Optima"}])> | |
<!--- Select the carModel field from the in memory table ---> | |
<cfquery name="myQuery" dbtype="query"> | |
SELECT carModel | |
FROM myCars | |
</cfquery> | |
<cfoutput> | |
<cfloop query="#myCars#"> | |
#carModel# | |
</cfloop> | |
</cfoutput> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- Setup an in memory database object ----> | |
<cfset myCars = queryNew("carModel","varchar",[{carModel:"Explorer"},{carModel:"Camaro"},{carModel:"Optima"}])> | |
<!--- Select the carModel field from the in memory table ---> | |
<cfquery name="myQuery" dbtype="query"> | |
SELECT carModel | |
FROM myCars | |
</cfquery> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset pets = ["dogs","cats","pigs"]> | |
<cfoutput> | |
<h1>Sounds a Pet Makes</h1> | |
<cfloop array="#pets#" item="breedName"> | |
<cfif breedName IS "dogs"> | |
Woof! | |
<elseif breedNAme IS "cats"> | |
meow! | |
<cfelse> | |
Thats an odd pet | |
</cfif> | |
</cfloop> | |
</cfoutput> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
<div> | |
##now()## | |
</div> | |
</cfoutput> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Home</h1> | |
<cfinclude template="navigation.cfm" /> | |
<p> | |
Page content about home | |
</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Servicess</h1> | |
<cfinclude template="navigation.cfm" /> | |
<p> | |
Page content about services | |
</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 basicTest(){ | |
savecontent variable="content" { | |
include template="basic_template.cfm"; | |
} | |
} | |
function conditionalLogicTest(){ | |
savecontent variable="content" { | |
include template="conditional_logic.cfm"; | |
} | |
} | |
function escapingOutputTest(){ | |
savecontent variable="content" { | |
include template="escaping_output.cfm"; | |
} | |
} | |
function includesTest(){ | |
savecontent variable="content" { | |
include template="home.cfm"; | |
include template="about_us.cfm"; | |
include template="services.cfm"; | |
} | |
} | |
function carsSelectTest(){ | |
include template="cars_select.cfm"; | |
} | |
function carsSelectTest(){ | |
include template="cars_output.cfm"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment