javascript - Underscore templates failing with "unexpected identifier" in IE 8 -


we have backbone / marionette web application. application works fine in modern browsers dies in ie8 with

script1010: expected identifier 

the debugger points line deep in underscore.js library rather in code. there isn't problem in library - our code triggering problem. line this

var render = new function(settings.variable || 'obj', '_', source); 

what problem be?

it turned out specific case in 1 of our template meant when template compiled, code fine in modern browsers threw wobbly in ie8.

we passing data in our view useful strings using serializedata function (coffeescript idea):

... serializedata: ->    data = super()    data.messages = {       intro: "welcome app"       continue: "click here continue"    }    return data ... 

then referencing in template so

<h1>{{ messages.intro }}</h1> <a href="...">{{ messages.continue }}</h1> 

the problem comes fact "continue" reserved word. coffeescript nice , allows use key in object definition without quoting, , appear in regular js in more modern browsers they're ok using unquoted (though 1 recommend so).

in ie8 may not set obj = { continue: "foo" } , may not obj.continue, must obj["continue"].

replacing {{ messages.continue }} {{ messages["continue"] }} or renaming property fixed issue.

hope helps :)

rob


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -