Escaping Quotes

jkchang's Avatar

jkchang

Oct 29, 2015 @ 06:42 PM

Hi my name is Jonathan and I am with UCSD's Campus Web Office.

I am currently attempting to escape quotes from an XML/HTML entity to parse into a JSON format. My question is when I try to use this section of code: ${_EscapeTool.javascript($outputTree)}
Where $outputTree is the result of a macro that generates a UL list. However, when I try to open the Test Format, I get the following error:

An error occurred while rendering asset preview: Error on line 3: Open quote is expected for attribute "class" associated with an element type "ul".

My first guess is Cascade detecting invalid XML markup and throwing the open quote error. Am I approaching the problem incorrectly?

Thank you in advance for the help.

Best,
Jonathan

  1. 1 Posted by Ryan Griffith on Oct 29, 2015 @ 07:27 PM

    Ryan Griffith's Avatar

    Hi Jonathan,

    Curious, but have you tried java() instead? This will just escape double quotes, which are reserved for surrounding the keys and values.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by jkchang on Oct 29, 2015 @ 08:35 PM

    jkchang's Avatar

    Hi Ryan,

    Thanks for looking into this issue.
    I used java() instead of javascript() but no such luck, the error remains the same.

    Best,
    Jon

  3. 3 Posted by jkchang on Oct 29, 2015 @ 09:03 PM

    jkchang's Avatar

    Attached are the index-block generated XML file as well as the velocity code where I try to escape the double quotes.

    within jsonParse-velocity.txt I had set the macro #Tree to just one line for output purposes. The #Tree macro will output a <ul> list of nav items.

    For reference, below is the output without the attempt to escape the quotes:

    JsonCallback ({"decorator.menu":"<ul class="navbar-list"><li><a href="/about/index">About</a><ul><li><a href="/about/team/index">Meet The Team</a></li><li><a href="/about/team/index">Electronic Accessibility</a></li><li><a href="/about/team/index">Campus Web Steering Committee</a></li></ul></li><li><a href="/prod-serv/index">Products &amp; Services</a><ul><li><a href="/prod-serv/cloud/index">cloud</a></li><li><a href="/prod-serv/cloud/index">Two-Column Template</a></li><li><a href="/prod-serv/cms/index">Content Management System (CMS)</a></li><li><a href="/prod-serv/user-exp/index">User Experience</a></li><li><a href="/prod-serv/user-exp/index">Web Decorator</a></li><li><a href="/prod-serv/user-exp/index">Mobile</a></li><li><a href="/prod-serv/user-exp/index">Common Requests</a></li></ul></li><li><a href="/support/index">Support</a><ul><li><a href="/prod-serv/user-exp/index">Contact Us</a></li><li><a href="/prod-serv/user-exp/index">CMS Mailing List</a></li><li><a href="/support/documentation/index">CMS Training Documentation</a></li><li><a href="/support/web-dev-resources/index">Web Development Resources</a></li></ul></li><li><a href="/contact/index">Contact</a></li></ul>"});

  4. 4 Posted by Ryan Griffith on Oct 30, 2015 @ 11:25 AM

    Ryan Griffith's Avatar

    Hi Jon,

    I am wondering if the error you are seeing is just a result of the XML validation process. Curious, but try using java or javascript and surround the entire output portion of your Format with a #protect code section. This will essentially tell Cascade to skip any sort of validation during rendering.

    Please let me know if you have any questions.

    Thanks!

  5. 5 Posted by Cristian Horta on Oct 30, 2015 @ 06:21 PM

    Cristian Horta's Avatar

    Hi Ryan,

    The #protect section tag worked, thank you for your help!

    Thanks,
    Cristian

  6. 6 Posted by Ryan Griffith on Oct 30, 2015 @ 06:33 PM

    Ryan Griffith's Avatar

    Thank you for following up, Cristian, I am glad to hear adding the code section did the trick.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  7. Ryan Griffith closed this discussion on Oct 30, 2015 @ 06:33 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac