python ternary in jinja2 gives TemplateSyntaxError: tag name expected

Viewed 14122

I have a table and I want to change background color of tr if value of person.storyPublished is true otherwise do nothing.

My code looks like this:

 {% for person in people %}
    <tr class="row-person {% '.row-story-published' if  person.storyPublished  else ' ' %}" >
    <td>
    {{ person.name }}
    </td>
    ...

I get this error:

jinja2.exceptions.TemplateSyntaxError
TemplateSyntaxError: tag name expected

and the CSS part is here:

<style>
    .row-story-published{
        background-color: #b3ffb3;
    }
</style>

why is this happening? What i miss that I don't notice? Any help :)

2 Answers
Related