When working on new logic and I want to dump a variable, I often use an internal CF_DumpLite CFC/CFTag that we developed that minimizes HTML output, honors original form & query column order & case, redacts CC values and is nonce aware. If I need to view the data types, I switch it up to use the cf_dump CFTag by Alexander Kwaschny.
We occasionally need to output data from an unordered struct in an email or to the webpage and it's not optimal to use either of these developer-centric dump tools for the general public. Even though we've been manually displaying tables for years, we've tended to repeat ourselves. I wrote this UDF in an effort to avoid having to do that.
structToTable is a ColdFusion UDF that will accept a struct with key-value pairs to generate legacy-valid, email-friendly html table and text-only key-value output.
We're now using this UDF when generating email messages so that we have both HTML and TEXT versions of the data. Enjoy!
Example Usage
result = structToTable(data=CGI,
keysToRemove="SERVER_PORT", sortOrder="https,auth_user");
writeoutput(result.html);
writeoutput("\<pre\>" & result.text & "\</pre\>");
Source Code
https://gist.github.com/JamoCA/bc5c58e829e191947f2e34289fd98a5a
Top comments (0)