Skip to content

Instantly share code, notes, and snippets.

@cfjedimaster
Created April 6, 2012 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfjedimaster/2320964 to your computer and use it in GitHub Desktop.
Save cfjedimaster/2320964 to your computer and use it in GitHub Desktop.
<cfparam name="url.files" default="">
<cfparam name="url.wrap" default="0">
<cfif not len(trim(url.files))>
<cfoutput>Files must be specified!</cfoutput>
<cfabort>
</cfif>
<cfset files = listToArray(url.files)>
<cfset extList = "js,html,css">
<!--- guess the file type --->
<cfset ext = listLast(files[1],".")>
<cfif listFind(extList,ext)>
<cfset ftype = ext>
<cfelse>
<cfset ftype = "html">
</cfif>
<cfset type = "text/" & (ftype eq "js"?"javascript":ftype)>
<cfset result = "">
<cfloop index="f" array="#files#">
<cfif listFind(extList, listLast(f, "."))>
<cfset contents = fileRead(expandPath("./"&f))>
<cfif wrap>
<cfset contents = "<entry url=""#f#"">" & contents & "</entry>">
</cfif>
<!--- consider stringbuilder here for perf --->
<cfset result &= contents>
</cfif>
</cfloop>
<cfheader name="Content-Lenth" value="#len(result)#">
<cfcontent type="#type#" reset="true"><cfoutput>#result#</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment