I am placing a <cfoutput>
tag around my entire <html>
tag. The ColdBox best practice guide states "When you are creating view templates, try to always surround it with 1 cfoutput tag, instead of nesting them all over the place."
But I have on occasion seen errors pop up where a <script>
block containing javascript code is within the <cfoutput>
tag. This probably because Coldfusion sees a hash #
and tries to parse it but it can't because its javascript.
So how does one get away with having a single <cfoutput>
tag on a view page in which to place everything?
I am not aware of any significant security or performance concerns in regards to wrapping an entire page in cfoutput. Of course, you'll always need to be aware to escape any pound signs by doubling them up any time you're inside a cfoutput.
The best practices in that ColdBox guide are geared primarily toward readability and reducing clutter on the page. If you have large sections of the page that you don't want to escape pound signs on or if you like to use cfoutput's grouping functionality, there's nothing wrong with breaking up your cfoutputs in a way that makes sense.
In the olden days of CF there might have been more overhead, but these days I can't imagine it being more than a few nanoseconds, and that's once at compile time.
In my view files I tend to wrap all output in a single cfoutput
tag.
You can escape #
symbols in JavaScript, etc, by converting them to ##
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With