logo

NJP

Jelly - Phase 2 - HTML escaping - CDATA - All your base are belong to us

Import · Feb 16, 2016 · article

Whenever I get a question about Jelly I start to sweat nervously. Then you throw in a question about phase 1 and phase 2 idiosyncrasies and I start to mumble like a crazy person. So, here's a little story I've got to tell -

Stephan Nolan, an employee working with me at RMIT, asked the question:

"We have a dynamic content block with the following:

<?xml version="1.0" encoding="utf-8" ?>



Hello World

</p> <p>&lt;![CDATA[<br><br> <label\><br><br> <input <br> name\="example" <br> type\="radio" <br> value\="1" <br> {{#if blah}}checked\="checked"{{/if}} <br> /\><br><br> <span\>Radio button</span\><br><br> </label\><br><br> ]]&gt;<br><br> </script\><br><br> &lt;/j:jelly&gt; </p> <p>Which works fine when two phase is turned off. However when we turn it on, the &lt;![CDATA[]]&gt; tags are being ignored and the following error is thrown </p> <p>Element type &quot;input&quot; must be followed by either attribute specifications, &quot;&gt;&quot; or &quot;/&gt;&quot;.: org.xml.sax.SAXParseException: Element type &quot;input&quot; must be followed by either attribute specifications, &quot;&gt;&quot; or &quot;/&gt;&quot;.:</p>

View original source

https://www.servicenow.com/community/developer-blog/jelly-phase-2-html-escaping-cdata-all-your-base-are-belong-to-us/ba-p/2269403