I am working with jija2. I am not sure weather I am missing something, but the mentioned if statement ({%if actors%}...{%endif%}
) does not seems to be working.
actors
is a list of movie names.
{%if actors%}
{%block movies%}
<div class='card-activity col-md-4' id="material-card-info">
<table class="table table-striped table-hover ">
<thead>
<tr>
<th><h5 style="color:#E91E63; font-weight:lighter; font-height:;">Actors</h5></th>
</tr>
</thead>
<tbody>
{%for actor in actors%}
<tr><td>{{actor}}</td></tr>
{%endfor%}
</tbody>
</table>
</div>
{%endblock%}
{%endif%}
Here's the view function:
@app.route('/movie/<b64>')
def profile_movie(b64):
profile = database_search_withid(b64) #returns a tuple eg: ('Avatar', 2012, ['Sam Worthington', 'Zoe Saldana'])
if not profile:
abort(404)
cast= json.loads(profile[2]) #list of actors obtained above is json
actor, actress = filter_feature(cast) #returns actor and actress in separate list
print show
return render_template('movie_profile.html', song_entries=profile, actors=actor, actresses=actress)
The div
inside {%if actors%}
is showing even when the list is empty. What am i missing?