Did you know you could do this?

So, I just found some interesting methods related to content buffering in
the page context that either slipped in recently, or I had been (not so)
blissfully unaware of until now. I imagine this is what cfsavecontent uses
under the hood, but using these methods directly gives you more control
over when to start/stop output buffering. It also works in ACF 11 (not
sure about previous versions).

index.cfm

writeoutput(“before buffering begins”);

buffer = GetPageContext().pushBody(); // push a new jsp writer onto the
stack and return the top

writeoutput(“buffered text - this will not make it out to the browser”);

// GetPageContext().getOut() will return the writer that is on top of the
stack, so right now, it will return the same object as “buffer”

GetPageContext().popBody(); // note, this pops the top writer off the
stack, and returns whatever what underneath it…
// also, if you do not pop the body, it gets flushed to the output stream,
as though you never began buffering

bufferedText = buffer.getString();

Anyways, I thought it was something cool. Definitely useful for what I’m
wanting to do.