Why do CFM templates being included with cfinclude need their own <cfoutput> wrappers?

coldfusion, coldfusion-10

Solution

Because each CFML file is compiled separately, and whether or not to output something is determined at compile time, not runtime.

Problem

I am using `<cfinclude>` to include various pages within a master page. In my master page all the body content is wrapped in `<cfoutput>` tags. However I noticed that after testing, the included .cfm page don't see the `<cfoutput>` tags at all and hence don't display the dynamic data. ``` <body> <cfoutput> <cfinclude template="page1.cfm" /> <cfinclude template="page2.cfm" /> <cfinclude template="page3.cfm" /> </cfoutput> </body> ``` In the above example, the included templates that have dynamic data in them will not display properly. To solve this I have to add `<cfoutput>` tags within each of the CFM files. How come they can't use the `<cfoutput>` tags that are already there within the body?

Original source