Last active
August 29, 2015 13:56
-
-
Save JamoCA/8938465 to your computer and use it in GitHub Desktop.
ColdFusion Custom Tag to allow all params to be safely passed regardless of ColdFusion version. Also removes comments & compresses whitespace.
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
<cfif thisTag.executionMode neq "start"><cfexit method="exitTag"></cfif><cfsetting enablecfoutputonly="YES"> | |
<!--- Server-based optimization technologies (like Google PageSpeed) may minify | |
or rewrite the HTML/JS/CSS and break CFDump's output. | |
Defaults for optional attributes, taken from the docs | |
http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_d-e_08.html ---> | |
<cfparam name="attributes.var" default=""> | |
<cfparam name="attributes.output" default="browser"> | |
<cfparam name="attributes.format" default="html"> | |
<cfparam name="attributes.abort" default="false"> | |
<cfparam name="attributes.label" default=""> | |
<cfparam name="attributes.metainfo" default="yes"> | |
<cfparam name="attributes.top" default="9999"> | |
<cfparam name="attributes.show" default="all"> | |
<cfparam name="attributes.hide" default="all"> | |
<cfparam name="attributes.keys" default="9999"> | |
<cfparam name="attributes.expand" default="yes"> | |
<cfparam name="attributes.showUDFs" default="yes"> | |
<!--- Call the original cfdump. (Which attributes you pass depends on CF version.) ---> | |
<cfsavecontent variable="DumpResults"> | |
<cfswitch expression="#listFirst(server.coldfusion.productVersion)#"> | |
<cfcase value="6"> | |
<cfdump var="#attributes.var#" expand="#attributes.expand#" hide="#attributes.hide#" label="#attributes.label#"> | |
</cfcase> | |
<cfcase value="7"> | |
<cfdump var="#attributes.var#" expand="#attributes.expand#" hide="#attributes.hide#" label="#attributes.label#" top="#attributes.top#"> | |
</cfcase> | |
<cfdefaultcase> | |
<cfdump var="#attributes.var#" expand="#attributes.expand#" format="#attributes.format#" hide="#attributes.hide#" keys="#attributes.keys#" label="#attributes.label#" metainfo="#attributes.metainfo#" output="#attributes.output#" show="#attributes.show#" showUDFs="#attributes.showUDFs#" top="#attributes.top#"> | |
</cfdefaultcase> | |
</cfswitch> | |
</cfsavecontent> | |
<cfif attributes.format neq "text" and attributes.output is "browser"> | |
<cfset DumpResults = rereplace(DumpResults, "[[:space:]]{2,}", " ", "all")> | |
<cfset DumpResults = replace(DumpResults, "> <", "><", "all")> | |
<cfset DumpResults = rereplace(DumpResults, "<!--[^>]+>", "", "all")> | |
</cfif> | |
<cfsetting enablecfoutputonly="No"> | |
<cfoutput>#DumpResults#</cfoutput> | |
<cfif yesnoformat(attributes.abort)> | |
<cfabort> | |
</cfif> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment