Code Sections
Digest
Cascade Server currently supports the use of two types of code sections in the system-- Passthrough Code Sections, and Root Code Sections.
Concept
Passthrough Code Sections
Passthrough code sections instruct the interpreter to exclude the enclosed code when the page is being previewed internally. Upon publishing, the contents of these tags will be uncommented and included in the final page.
Root Code Sections
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.Technical
Passthrough Code Section Tags
The passthrough code section is delimited as follows:
When viewing a file or page containing these types of blocks within the CMS, these sections are left untouched unless the asset is a page with serialization type of PDF or RTF (as determined by the Target associated with the page's Template). If the serialization type is PDF or RTF the section is simply stripped from the code.
When publishing a file or page containing these blocks to a location outside the CMS, these sections are rewritten so that the enclosing comments and "#START-CODE"/"#END-CODE" strings are removed. However, when publishing a page with PDF or RTF serialization type, these sections are once again completely removed rather than rewritten.
For example, suppose we wanted to embed the following PHP code in a page:
Wrapping the passthrough code comment tags allows the page to validate as XML:
When viewing this page in the system, this code would remain inside of the comments untouched; and the PHP code will not render (unless a PDF or RTF configuration of a page is viewed, in which case the comments and the code would be removed).
However, upon publishing to a file with serialization type of HTML or XML, the comment tags are stripped out leaving only the valid PHP code:
When publishing to a PDF or RTF file, or viewing a PDF or RTF configuration of the page within the system, the comments and the code would both be stripped out.
Root Code Sections
The second type of code section currently supported in the system is the root code section, which 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. This can be useful if, for example, you need to include a page redirect at the top of the page, but you are using a template that does not have a content region defined at the very top.
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.
The following root code section tags could be used 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.

