CFScript Question: WriteDump() on a new line
Is there a way to make writeDump() easily output to a new line when using this within a <cfscript> block?
Is there a way to make writeDump() easily output to a new line when using this within a <cfscript> block?
Do you mean because the thing you’re dumping is just a simple variable being output? As opposed to something like a query, struct, array, or CFC where it creates a table of output (implicitly on a new line from whatever was output above it)?
If so, then it seems your answer is “no”. And this is no different than a CFDUMP. You just have always needed to add an html br tag before or after dumping a simple variable, if you wanted the dumped variable to be on its own line.
Of course, with CFDUMP you could just add that before or after that tag, but with writedump, you’d have to do a writeoutput of a br tag, and I agree that’s annoying.
BTW, someone may want to suggest, why don’t you just do the br tag within the writedump separated with an &. I’ll try it here, but I don’t know if it will render in this forum:
writedump(somesimplevar & "<br>");
That doesn’t work, because the writedump just htmlencodes the output, such that if somesimplevar was = 1, the result would be:
1<br>
Edit: Of course, you could just use writeoutput instead, if you KNEW it was indeed a simple variable. But if your point is that when you do the writedump you don't know if it will be or not, then I can appreciate your challenge here.
So really, this could be a nice feature request for you to add (at tracker.adobe.com), to add an argument to allow for that. (As it stands, the writedump takes all the same arguments as CFDUMP had for attributes, but there was no real need for a CFDUMP attribute like this need you’re describing—but it wouldn’t hurt to have it for CFDUMPs of simple variables also).
/charlie
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.