In Defense of CFCs for Output
A just read a comment arguing against output CFCs as more difficult to maintain than Custom Tags. As this differs somewhat from my experience, I wanted to explore the idea.
In a comment to blog entry by Terrence Ryan, Sean Corfield said that he thought designers could edit Custom Tags easier than CFCs. This because they could use their WYSIWYG editors on the custom tags.
I agree if the output is limited to a small widget. If the output is the for the layout (the overall design) of the page, however, I would disagree.
My problem with using Custom Tags for layout comes from the need to have different parts of the design in different custom tags (or using an awkward "action" attribute).
Using Output CFCs allows me to have the layout in only one file - which just like an HTML file of the design (once you ignore the cffunction tags - easy to do). This is easy to edit for anyone that knows HTML. For others, you could save it as a .html file for WYSIWYG editing and back again (though I have yet to have that need).
This is far outweighed by the advantages of this approach. Among them having all of the layout in one file, the ability to easily switch between different layouts, the ability to easily switch to different output formats (PDF,Word,etc), and the ability to easily gain control over the <head> for any page.
Since I am too lazy to rehash these benefits completely, I will just point you to my article on Handling Layouts with Components. Feel free to download some example layout components as well.
Note that if you are worried about the performance implications of this approach, Terrence Ryan's blog entry covers that pretty well. Of course, he isn't using the exact approach that I am, but I think the point remains valid.
Brian Kotek
That is a fair point. The problem with that approach is that you are limited to 2 output points.
I usually have a layout.head() (for everything above ), a layout.body() (for and the top of the design), and a layout.end() (for everything after the main content).
This allows me to put code in the of the page by merely placing it between the call to layout.head() and layout.body(). So, if I have some JavaScript that is specific to that page, for example, I can put it there.
In rare cases, I have also had a design that calls for a menu in a weird place and so I can add a layout.menu() for that.
This ends up having a lot more flexibility than custom tags, especially because I can still place those in the correct order in the CFC which keeps it easy to edit as well.