0

I working on a Django template in Javascript where I'm checking if the user is logged in before displaying a button inside of a list element. For some reason, I'm getting the error: Could not parse the remainder: '% if user.is_authenticated %' from '% if user.is_authenticated %'

Here is the code that is causing the error:

$list.append("<li class='list-group-item'>Artist: {{form_artistSelect}}  Location: " + venues[i].city + ', ' + venues[i].region +' Venue: ' + venues[i].name + 
       "Date: " + dates[i] + "tickets status: " + ticket_statuses[i] + "<br><a href = '" + ticket_urls[i] +"'" + "> ticket link</a>  
       {{% if user.is_authenticated %}} //This line is causing the error
            <button id ='invite'type='button' class='btn btn-info btn-lg' data-toggle='modal' data-target='#myModal' venue= " +venues[i] +" date = "+ dates[i] +"ticket_url = "+ticket_urls[i]+" artist = {{form_artistSelect}} >Invite a friend</button>  <button id = 'save' type='button' class='btn btn-primary-outline'> Save concert</button> 
        {{% endif %}}
            </li>"); 

Why is the if statement being parsed as the modulus operator? I have the same syntax in other parts of the file and that has been working.

loremIpsum1771
  • 2,497
  • 5
  • 40
  • 87

1 Answers1

2

I think you are using some extra brackets, try with:

{% if user.is_authenticated %}

instead of:

{{% if user.is_authenticated %}}
fasouto
  • 4,386
  • 3
  • 30
  • 66
  • Thanks for the response, but now I'm getting a ```SyntaxError: unterminated string literal``` Am I missing a close quote somewhere? It doesn't look like it. – loremIpsum1771 Dec 24 '15 at 03:46
  • I think it's related to JS formatting, see http://stackoverflow.com/questions/5296402/unterminated-string-literal – fasouto Dec 24 '15 at 03:48
  • And don't forget to remove the extra brackets of endif! :) – fasouto Dec 24 '15 at 03:49