Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EJS templates error in Internet Explorer 9 #117

Open
ecentinela opened this issue Feb 23, 2012 · 9 comments
Open

EJS templates error in Internet Explorer 9 #117

ecentinela opened this issue Feb 23, 2012 · 9 comments

Comments

@ecentinela
Copy link

I get an error when trying to create a EJS template in IE9.

The code is:

new $.EJS({text: '<div>a test</div>'})

The error says:

Can't get the value for the property 'js': the object is null or is not defined

You can test the code on the same IE console.

@justinbmeyer
Copy link
Member

How are you running IE9? OS / VM? Standards / Quirks mode?

@ecentinela
Copy link
Author

Tested on a OSX VMWare Fusion with IE9 (811216421) with all compatibility modes.
Tested on another computer with Windows 7, IE9 (811216421)) with all compatibility modes.

Same error on both machines.

@moschel
Copy link
Member

moschel commented Feb 23, 2012

In my IE9 with latest jquerymx, in the console:

new $.EJS({text: '

a test
'})
{
type : "<",
ext : ".ejs",
text : "
a test
",
template : [object Object],
render : function( object, extraHelpers ) { object = object || {}; this._extra_helpers = extraHelpers; var v = new EJS.Helpers(object, extraHelpers || {}); return this.template.fn.call(object, object, v); }
}

Are you trying this with latest from master? And you don't see what I see?

@ecentinela
Copy link
Author

No, I'm not using the master branch.
I'm using the downloaded from the website (https://github.com/downloads/jupiterjs/javascriptmvc/javascriptmvc-3.2.2.zip)

@justinbmeyer
Copy link
Member

Can you try it with just replacing your version of EJS with the latest at:

https://raw.github.com/jupiterjs/jquerymx/master/view/ejs/ejs.js

and see if it works?

@ecentinela
Copy link
Author

I tried now and same error.
I created a gist with the complete jmvc3.2.2 file that I'm using. Is a concatenation of all files given on the build.js script.
Hope it helps https://gist.github.com/1899680

@ecentinela
Copy link
Author

After some more debug, I saw that the error comes from an incompatibility with "ckeditor".
Some more research has show me that the error comes from this line on "ejs.js":

myEval.call(out, 'this.fn = (function(_CONTEXT,_VIEW){' + out.out + '});\r\n//@ sourceURL=' + name + ".js");

The 'myEval' function, tries to eval this code:

this.fn = (function(_CONTEXT, _VIEW){try { with(_VIEW) { with
(_CONTEXT) {var ___v1ew = [];___v1ew.push("<p>test</p>");; return
___v1ew.join('')}}}catch(e.lineNumber=null;throw e;}});
//@ sourceURL=undefined.js

Seems that IE9 tries to search for a variable called 'undefined.js' regardless the '//'. Quite strange.
If I remove this line for any one of the next lines, all is ok:

myEval.call(out, 'this.fn = (function(_CONTEXT,_VIEW){' + out.out + '});');

or:

myEval.call(out, 'this.fn = (function(_CONTEXT,_VIEW){' + out.out + '});\r\n// sourceURL=' + name + ".js");

Hope this helps.

@asavoy
Copy link

asavoy commented Feb 28, 2012

Isn't this ultimately the old conditional comments issue?

I believe JavascriptMVC used to use //@ for its preprocessor commands, e.g. //@steal-remove-start. This clashed with the syntax used for IE's conditional comments, but only when they are "enabled" through a //@cc_on@ directive. CKeditor, SWFobject and other 3rd party libraries commonly do this. My app is uses both. :(

Seems JavascriptMVC changed to //! but perhaps not all refs were updated? So isn't the correct fix to apply the same here? That troublesome comment doesn't appear to be anything but for debugging purposes anyway.

@ecentinela
Copy link
Author

Thanks asavoy, it makes a lot of sense for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants