{% if items[0].__str__() == 'HTMLVariableInfo' %} {# Variable summary row: name and key statistics | main chart | extra statistics. The first table joins the name; the first non-table item (chart, frequency bars, word cloud) is the main visual. #} {% set ns = namespace(tables=[], visuals=[]) %} {% for item in items[1:] %} {% if item.__str__() == 'HTMLTable' %} {% set ns.tables = ns.tables + [item] %} {% else %} {% set ns.visuals = ns.visuals + [item] %} {% endif %} {% endfor %} {% set main = ns.visuals[:1] if ns.visuals else ns.tables[1:2] %} {% set side = (ns.tables[1:] if ns.visuals else ns.tables[2:]) + ns.visuals[1:] %}