Listing 1

<cfoutput>#layout.head('My Title')#</cfoutput>
  <style type="text/css">.myclass {color:blue}</style>
<cfoutput>#layout.body()#</cfoutput>

Page Contents...

<cfoutput>#layout.end()#</cfoutput>

Listing 2

<cfset layout = layout.switchLayout("Home")>
<cfoutput>#layout.head('My Title')#</cfoutput>
<cfoutput>#layout.body()#</cfoutput>

Home Page Contents...

<cfoutput>#layout.end()#</cfoutput>

Listing 3

<cfcomponent displayname="Default Layout" extends="layout">
<cffunction name="head" access="public" output="yes">
<cfargument name="title" type="string" required="yes">
<html>
<head>
  <title>#arguments.title#</title>
</cffunction>
<cffunction name="body" access="public" output="yes">
</head>
<body>
</cffunction>
<cffunction name="end" access="public" output="yes">
</body>
</html>
</cffunction>
</cfcomponent>

Listing 4

<html>
<head>
  <title>My Title</title>
  <style type="text/css">.myclass {color:blue}</style>
</head>
<body>

Contents...

</body>
</html>

Listing 5

<cfcomponent>

<cffunction name="init" access="public" returntype="layout" output="no">
  
  <cfset variables.me = StructNew()>
  
  <cfreturn this>
</cffunction>

<cffunction name="switchLayout" access="public" returntype="layout" output="no">
  <cfargument name="layout" type="string" required="yes">
	
  <cfset var result = CreateObject("component",layout).init()>
  
  <cfset result.setMe(variables.me)>
  <cfset this = result>
  
  <cfreturn result>
</cffunction>

<cffunction name="setMe" access="package" returntype="void" output="no">
  <cfargument name="me" type="struct" required="yes">
  
  <cfset variables.me = me>
  
</cffunction>

<cffunction name="head" access="public" output="yes"></cffunction>
<cffunction name="body" access="public" output="yes"></cffunction>
<cffunction name="end" access="public" output="yes"></cffunction>

</cfcomponent>\