Created
April 6, 2012 15:52
-
-
Save cfjedimaster/2320964 to your computer and use it in GitHub Desktop.
This file contains 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
<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