2

I have a jinja2 template being processed that includes:

<td>{{ '' if group[2] }} {{ group[2] }}</td>

I'm trying to add the to all items that contain group[2]. I want to include entries where a value exists including None. Currently the following is produced:

enter image description here

How can I modify {{ '' if group[2] }} so it runs for variables that have values including None.

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225

1 Answers1

5

You can achieve that using Jinja2's is defined test:

<td>{{ '' if group[2] is defined }} {{ group[2] }}</td>
Bovarysme
  • 453
  • 3
  • 10