After executing this template we would get:
This is not exactly what we would like to get. The compiler must have broken the CDATA section in order to display a variable value, and then open it again. It does not look nice and moreover, many browsers could have problems with parsing it properly. A solution is provided by the
opt:literal instruction which controls the CDATA section behaviour:
opt:literal makes the CDATA delimiters in the template not to be sent to the browser, although they are still parsed properly. What is more, the instruction allows to pack the content with one of four delimiter types selected with the
cdata- the content is packed within
comment_cdata- the content is packed within
/* <![CDATA[ */and
/* ]]> */.
comment- the content is packed within
-->(a dynamic comment).
transparent- does not pack the content within anything. It just hides the
]]>delimiters in the content.
So, the final result of our template will be:
The same trick can be used to create conditional Internet Exporer comments. We leave it as an exercise for you.