Cascade Server currently supports the use of two types of code sections in the system-- Passthrough Code Sections, and Root Code Sections.
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.
Passthrough-top Code SectionsThe passthrough-top 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 passthrough-top code section.
Skipping CodeIt is possible to completely remove fragments of code both from rendering inside of Cascade Server and when publishing. It is also possible to remove portion of the rendering from given point to the end of that entire rendering.
Passthrough Code Section Tags
The passthrough code section is delimited as follows:
This deprecated way is also allowed:
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 #passthrough 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.
Passthrough-top Code Sections Tags
The second type of code section currently supported in the system is the passthrough-top code section, which is delimited as follows:
This deprecated way is also allowed:
The passthrough-top 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 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 passthrough-top 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.
Protect code sections are delimited as follows:
Below you will find an example that outputs unbalanced XML that could be used to aid the support of older web browsers.
This will result in following code which normally (without use of code sections) would not be allowed by Cascade Server:
The syntax for client root code section is delimited as follows:
<!--#protect-top...put any code here...#protect-top-->
<![CDATA[#protect-top...put any code here ...#protect-top]]>
During the last stage of rendering the Page, the special syntax is stripped leaving the text ...put any code here... in the example above and that text is then being moved above the XML document.
The following code can be used to output the HTML 5 Boilerplate (h5bp) code:
The result of this code will be:
Cascade Skip TagsIn some situations it is useful to completely remove part of the code. This is possible through outputting #cascade-skip tag inside of HTML comments. For example, the code below:
will result with the <unnecessary-tag/> being removed after the page finishes rendering, right before it is published out or outputted to the screen:
Placing only one <!--#cascade-skip--> tag results with the remaining contents being fully stripped. This is especially useful together with the #protect-top tag. For example, this valid XML document: