3

Trying to figure out why I can't seem to intern strings in my dojo build. My layer files get created correctly, but the code associated with each of the individual dijits doesn't get interned properly.

Here is a piece of portion of the build output that illustrates where it is failing:

release:  Interning strings for : ../../release/fwijits5.31.2012/content/fwijits/optionalDijits/commenting.js
release:      ../../release/fwijits5.31.2012/content/fwijits/optionalDijits/templates/commenting.htm
release:  Optimizing (shrinksafe, stripConsole=normal) file: ../../release/fwijits5.31.2012/content/fwijits/optionalDijits/commenting.js
release:  Could not strip comments for file: ../../release/fwijits5.31.2012/content/fwijits/optionalDijits/commenting.js,

error: InternalError: illegal character

It looks like the optimize fails because the template doesn't get added to the js file properly. Here is what the js looks like after the html gets interned. You can't tell from the output, but a byunch of special characters get tacked on at the end of the javascript.

if(!dojo._hasResource["fwijits.optionalDijits.commenting"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["fwijits.optionalDijits.commenting"] = true;
dojo.provide("fwijits.optionalDijits.commenting");

dojo.require("dijit._Widget");
dojo.require("dijit._Templated");

dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.TabContainer");


//The main widget that gets returned to the browser
dojo.declare("fwijits.optionalDijits.commenting", [dijit.layout.ContentPane, dijit._Templated], {

  widgetsInTemplate: true,
  _earlyTemplatedStartup: true,
  templateString: dojo.cache("fwijits.optionalDijits", "templates/commenting.htm"),
  basePath: dojo.moduleUrl("fwijits.optionalDijits"),

  //This function contains all configurable parameters
  constructor: function(params){
    params = params ||{};
    this.inherited(arguments);
  },

  //This functions run on a "startup" call
  startup: function(){
    var _this = this;

    this.inherited(arguments);
  },

  _addPointComment:function(){
    console.debug("button clicked");
  }

});

}

The htm file is pretty simple, so I don't think it's the root of my problem.

<div dojoAttachPoint="containerNode">
  <div dojoattachpoint="_outerDiv">
    <div dojoattachpoint="_addPoint" dojotype="dijit.form.Button" dojoattachevent="onClick:_addPointComment"><b>Add Comment</b></div>
  </div>
</div> 

Any suggestions?

Danubian Sailor
  • 1
  • 38
  • 145
  • 223
wrdaigle
  • 43
  • 3
  • Are you sure it's related to the interning of the templateString? What happens if you replace the dojo.cache statement with just "
    foo
    "?
    – Frode Jun 03 '12 at 12:14
  • You're right, I still get the error even if I replace the dojo.cache statement. Any ideas what the problem could be? – wrdaigle Jun 07 '12 at 14:36
  • No, hard to tell. You are absolutely sure your commenting.js doesn't have any weird invisible characters? Does it also happen if you disable comment stripping or some of the other optimizations? – Frode Jun 07 '12 at 15:16
  • The only thing that helped matters was stopping the layer from being created. As it turns out, this is fine for my purposes. I can't really do a full build anyway since I need to load a third party layer (ESRI's javascript API) as well. I haven't really figured out how to bake their layer in a single layer that I load on my site, so I have been jumping through hoops to load both layer files. Instead, I will just use the build process to compress and intern my files, then load my code as a dijit instead of a layer file. – wrdaigle Jun 07 '12 at 19:16

1 Answers1

0

Which version of Dojo? There is a bug in the build system with interning strings that do not end in HTML or HTM, although I've never tried with HTM to know for sure.

Might be worth a check. I know this was fixed in 1.7 and backported to 1.8.

https://bugs.dojotoolkit.org/ticket/15867

sma
  • 9,449
  • 8
  • 51
  • 80