Skip to content

Instantly share code, notes, and snippets.

@roryl
Last active March 11, 2016 10:46
Show Gist options
  • Save roryl/708a488afcf4a86f1931 to your computer and use it in GitHub Desktop.
Save roryl/708a488afcf4a86f1931 to your computer and use it in GitHub Desktop.
Lucee Template Examples
<h1>About Us</h1>
<cfinclude template="navigation.cfm" />
<p>
Page content about us
</p>
<cfoutput>
<div>
#now()#
</div>
</cfoutput>
<!--- 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>
<!--- 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>
<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>
<cfoutput>
<div>
##now()##
</div>
</cfoutput>
<h1>Home</h1>
<cfinclude template="navigation.cfm" />
<p>
Page content about home
</p>
<ul>
<li>Home</li>
<li>Services</li>
<li>About Us</li>
</ul>
<h1>Servicess</h1>
<cfinclude template="navigation.cfm" />
<p>
Page content about services
</p>
/**
* 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