Executes another template within the current template




Attribute default required summary
ATTRIBUTECOLLECTION A structure containing the tag attributes
TEMPLATE The path to the template to execute
PAGE If no TEMPLATE, then the PAGE can be used, which is the URL for include
RUNONCE If this flag is set, then the template is only rendered once, even if included later on in the request, without this flag set


This tag, as well as its function version RenderInclude(), lets you include any page referenced (rendered as CFML) into the current position of the template. This is another way to split up common functionality.

A handy flag here is the runonce attribute. This stops the referenced template from being included more than once in the given request. An example of this usage is if you used your included template to setup in-page functions (or even Javascript snippets), you can liberally put this file through your request files and it would only ever get rendered once. Naturally this is discouraged from a code maintenance point of view.

Consider the following example. The template "" would only get executed once, with the engine skipping over the next calls. This works throughout the request, even if the include is called from a different template with a different path.

<cfinclude template="" runonce="true" />
<cfinclude template="" />
<cfinclude template="" />