0

I am getting an unexpected token { in the following line:

var that = this, tag_array = "img,object,embed,audio,video,iframe".split(','), 
 video_array = ['EMBED', 'OBJECT', 'VIDEO'], 
 is_ooyala = false, platform = {{ platform }};

seems like every thing is in balance. Any idea?

5
  • Are you using flowplayer for videos? Commented Jan 25, 2012 at 19:07
  • @RobW what is the issue with that? Commented Jan 25, 2012 at 19:08
  • {{ platform }}; is causing the error. What do you want to achieve? Commented Jan 25, 2012 at 19:08
  • I believe he is using the Django Template Language and platform is a variable sent from a Python View. To use it in JavaScript you need double quotes: "{{ platform }}" Commented Jan 25, 2012 at 19:16
  • For future reference try to describe all languages and libraries you're using in your question. Commented Jan 25, 2012 at 19:17

6 Answers 6

1

{{ platform }} is not valid, I am not sure what you are trying to do there to tell you how to fix it.

Sign up to request clarification or add additional context in comments.

Comments

1

This part is causing an error:

platform = {{ platform }}

There are two issues there. First, an object would contain key: value pairs, not just a single value and second, you can't use a variable itself in the declaration of that same variable.

I'm unsure what you're trying to accomplish so don't know what solution to recommend.

Comments

1

At the end of the line is what looks to be a nested object, but since it has no property name it is a syntax error:

platform = {{ platform }}

This was maybe intended to be something like

platform = { someProperty: { platform }}

Comments

0

Unless this is dJango (in which cas you need to surround the {{platform}} in quotes(platform = "{{ platform}}";), you're setting a variable equal to iteslf inside a double object litteral... As everyone is saying this:

platform = {{ platform }};

is your issue. for testing switch to:

platform = "";

or try:

platform = {0: platform}

And you can revrive the value like this:

var x = platform.0;

or

var x = platform[0];

Comments

0

Objects are associative, you're trying to put an object inside of an object without a key, try using dissociative arrays, or give the object a key {"Key:{"platform":platform}}

var that = this, tag_array = "img,object,embed,audio,video,iframe".split(','), 
 video_array = ['EMBED', 'OBJECT', 'VIDEO'], 
 is_ooyala = false, platform = [[ platform ]];

Comments

0

It seems from the {{ platform }} that you are using a Django Template.

var that = this, tag_array = "img,object,embed,audio,video,iframe".split(','),video_array = ['EMBED', 'OBJECT', 'VIDEO'],is_ooyala = false,platform = "{{ platform }}"

To use django template variables in javascript you need the quotes

2 Comments

He never said anything about django.
Seemed like he's using the template language due to the double curly braces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.