Root Code Section
Author: Bradley Wagner
The second type of code section currently supported in the system is the root code section. It is delimited as follows:
The root code section is used to support code that must be placed at the very beginning of a document (file or page) – for example, an ASP page that requires a processing instruction before the page's DOCTYPE. Because the system does not allow for XML comments before the root element or for DOCTYPE in a Template, such code must be placed inside of a root code section.
The rules for rendering these code sections both inside and outside of the CMS are the same as for the passthrough code section with one notable difference - when publishing to a file or page with serialization type HTML or XML, the comment tags are removed, but the code inside the comments is actually moved to the beginning of the document.
For example, suppose you have the following .NET template:
Therefore, when a page using this template was published, the ASP instructions would appear before the page's DOCTYPE.
You could use the root code section tags to create this template in the CMS:
If there were multiple root code sections in a page or file, they would be placed sequentially at the top of the document in the relative order that they appeared.