I have a HTML/jinja2 template that I am using to display data in the form of a table.
The data for the table may come in different ways, and I want the template to be able to handle both types using if statements. the type(x) function in python does not work in this language.
an array of dictionaries (list of dictionaries)
an array of arrays (list of lists)
a part of the template:
{% block page_content %}
<input type="text" id="search" placeholder="Type to search">
<table id="table" class="table">
<tr style="white-space:nowrap;">
{% for h in headers %}
{% if h is string %}
<th>{{h}}</th>
{% else %}
<th>{{h[1]}}</th>
{% endif %}
{% endfor %}
</tr>
{%if data is "TYPE CHECK HERE"}
{% for row in data %}
{% if row != {} %} #ALTERNATIVELY, COULD DO A TYPE CHECK HERE
<tr style="white-space:nowrap;{% if row['bad'] %}background-color:rgba(255, 0, 0, 0.09);{% endif %}">
{% for h in headers %}
<td style="white-space:nowrap;">{{ row[h[0]] }}</td>
{% endfor %}
</tr>
{% endif %}
{% endfor %}
{% endblock %}
TL:DR What are the distinguishable types in jinja2? How do I check a variable's type?