We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27672
    • 168 Posts
    i’m trying to write something like this:

    $(document).ready(function() 
        { 
            $("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} ); 
        } 
    );
    


    in a template, but it’s not showing up in the source code. i believe modx is trying to interpret [[0,0], [1,0]] as a snippet named: "0,0], [1,0" how can i escape the [ and ] characters so they are seen as literal text?

    tried googling, but everything that came up with "modx escape" seemed to deal with escaping user input for database purposes. thanks you for any advice!
      • 27672
      • 168 Posts
      am able to bypass this for now, but just putting the javascript into an external file, but would still be interested to know if there’s a way to escape the [ ] characters. thanks.
        • 22303 MODX Staff
        • 10,725 Posts
        Yes, this is a problem with the double brackets, and the easiest way to get around this for now, is to add spaces in between two successive brackets, e.g. this should work fine:
        [ [ 0,0 ], [ 1,0 ] ]
          • 27672
          • 168 Posts
          thank you very much, i didn’t think to try spacing out my brackets. i would have assumed that since javascript and other languages can read array syntax with spaces in it, that so could modx - though perhaps modx was purposely coded to not be able to read [ [ 1,0 ] ] for cases just as this one. again thank you.
            • 44659
            • 20 Posts
            I know it's veeery old post, but i'm wondering what about CDATA tags, which MUST use "]]>" at the end? It's closing ALL MODx tags (not only comments) which is highly adverse.

            eg.:
            [[- Temporarily, i dont want to see that on my page source from here...
               <![CDATA[
                 some content...
               ]]>
               ... to here, but the line above breaks everything
            ]]
            
              • 3749
              • 24,544 Posts
              In Revolution, you can do this:

              [[-some content]]

              MODX will consider that a comment and will strip the tag from the output.

                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting