Reputation: 7563
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?
Upvotes: 5
Views: 497
Reputation: 480
The simple answer to your question as posted is yes.
There are only two issues that I'm aware of to keep in mind:
My preference is to use as few tags as possible, mostly for readability and to reduce clutter.
Upvotes: 0
Reputation: 3953
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.
Upvotes: 3
Reputation: 1310
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 ##
.
Upvotes: 2