Announcement

Collapse
No announcement yet.

Javascript Embedded in compiled program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Javascript Embedded in compiled program

    Previously I embedded Javascript in a compiled program by wrapping it inside CDATA tags.

    //<![CDATA[
    ... Javascript ...
    //]]>

    But the 5.23 compiler is throwing an error

    After some experimenting, I found I can use the following, but my question is why did this change?

    //<!--
    ... Javascript ...
    //-->
    Ray Yates
    "If I have seen further, it is by standing on the shoulders of giants."
    --- Sir Isaac Newton

    #2
    Re: Javascript Embedded in compiled program

    No idea on why it changed, but CDATA is supposed to only be for XML/SGML, outside of that it has no real meaning AFAIK.

    The second method is what Miva has been using for years in a few places (such as export modules).

    I may be unaware of something, but are we talking client-side JavaScript? I've always just embedded the script tags without any commenting inside compiled modules. Are you trying to avoid script tags?
    Gordon Currie
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit Any Document Easily | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      Re: Javascript Embedded in compiled program

      Thanks Gordon,

      I'm not sure why I started using CDATA unless it was in an example I saw on the web. I've routinely had the compiler choke on particular lines of javascript for no apparent reason, but adding <!-- --> seems to get around the issue.

      Interesting Tip.

      My Map Location module has a dozen external files. I want to avoid users having to FTP these manually, so I embed these files directly into the MVC file as follows.

      I have 1 function called Generate_Code() that I call to retrieve the external files which then get written to the website or applied as needed. This lets me maintain these files outside my application and only include them during compilation.

      Code:
      <MvFUNCTION NAME = "Generate_Code" PARAMETERS = "code, template var" STANDARDOUTPUTLEVEL = "">
      
      <MvIF EXPR="{ l.code EQ 'map_locations_cssui.mvt' }">
              <MIVA STANDARDOUTPUTLEVEL="html, text"><MvCAPTURE VARIABLE = "l.template"><MvINCLUDE FILE = "templates/map_locations_cssui.mvt"></MvCAPTURE><MIVA STANDARDOUTPUTLEVEL=""><MIVA STANDARDOUTPUTLEVEL="">
      
      <MvELSEIF EXPR="{ l.code EQ 'map_locations.js' }"> etc.
      Ray Yates
      "If I have seen further, it is by standing on the shoulders of giants."
      --- Sir Isaac Newton

      Comment

      Working...
      X