{%- if filetype_loop == 0 %}VRF,Address Family,Instance,Area,LSA Type,LSA,Age,Link Count,Check Sum,Sequence Number
{%-     for vrf in to_parse_ip_ospf_database %}
{%-         for address_family in to_parse_ip_ospf_database[vrf].address_family %}
{%-             for instance in to_parse_ip_ospf_database[vrf].address_family[address_family].instance %}
{%-                 for area in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas %}
{%-                     for lsa_type in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types %}
{%-                         for lsa in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas %}
{{ vrf }},{{ address_family }},{{ instance }},{{ area }},{{ lsa_type }},{{ lsa }},{{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.age }},{{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.link_count }},{{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.checksum }},{{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.seq_num }}
{%-                         endfor %}
{%-                     endfor %}
{%-                 endfor %}
{%-             endfor %}
{%-         endfor %}
{%-     endfor %}
{%- else %}
{%-     if filetype_loop == 1 %}
# Show IP OPSF Database
| VRF | Address Family | Instance | Area | LSA Type | LSA | Age | Link Count | Check Sum | Sequence Number |
| --- | -------------- | -------- | ---- | -------- | --- | --- | ---------- | --------- | --------------- |
{%-         for vrf in to_parse_ip_ospf_database %}
{%-             for address_family in to_parse_ip_ospf_database[vrf].address_family %}
{%-                 for instance in to_parse_ip_ospf_database[vrf].address_family[address_family].instance %}
{%-                     for area in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas %}
{%-                         for lsa_type in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types %}
{%-                             for lsa in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas %}
| {{ vrf }} | {{ address_family }} | {{ instance }} | {{ area }} | {{ lsa_type }} | {{ lsa }} | {{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.age }} | {{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.link_count }} | {{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.checksum }} | {{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.seq_num }} |
{%-                             endfor %}
{%-                         endfor %}
{%-                     endfor %}
{%-                 endfor %}
{%-             endfor %}
{%-         endfor %}
{%-     else %}{% if filetype_loop == 2 %}
<html><body>
<h1>Show IP OSPF </h1>
<table>
  <thead>
  <tr>
    <th>VRF</th>
    <th>Address Family</th>
    <th>Instance</th>
    <th>Area</th>
    <th>LSA Type</th>
    <th>LSA</th>
    <th>Age</th>
    <th>Link Count</th>
    <th>Check Sum</th>
    <th>Sequence Number</th>
  </tr>
  </thead>
  <tbody>
{%-         for vrf in to_parse_ip_ospf_database %}
{%-             for address_family in to_parse_ip_ospf_database[vrf].address_family %}
{%-                 for instance in to_parse_ip_ospf_database[vrf].address_family[address_family].instance %}
{%-                     for area in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas %}
{%-                         for lsa_type in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types %}
{%-                             for lsa in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas %}
  <tr>
    <td>{{ vrf }}</td>
    <td>{{ address_family }}</td>
    <td>{{ instance }}</td>
    <td>{{ area }}</td>
    <td>{{ lsa_type }}</td>
    <td>{{ lsa }}</td>
    <td>{{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.age }}</td>
    <td>{{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.link_count }}</td>
    <td>{{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.checksum }}</td>
    <td>{{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.seq_num }}</td>
  </tr>
{%-                             endfor %}
{%-                         endfor %}
{%-                     endfor %}
{%-                 endfor %}
{%-             endfor %}
{%-         endfor %}
  </tbody>
</table>
</body></html>
{%-         else %}
# Show IP OSPF Database
{%-             for vrf in to_parse_ip_ospf_database %}
{%-                 for address_family in to_parse_ip_ospf_database[vrf].address_family %}
{%-                     for instance in to_parse_ip_ospf_database[vrf].address_family[address_family].instance %}
## {{ vrf }} - {{ address_family }} - Instance: {{ instance }}
{%-                         for area in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas %}
### Area: {{ area }}
{%-                             for lsa_type in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types %}
#### LSA Type: {{ lsa_type }}
{%-                                 for lsa in to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas %}
##### LSA: {{ lsa }}
###### Age: {{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.age }}
###### Link Count: {{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.link_count }}
###### Checksum: {{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.checksum }}
###### Sequence Number: {{ to_parse_ip_ospf_database[vrf].address_family[address_family].instance[instance].areas[area].database.lsa_types[lsa_type].lsas[lsa].ospfv2.header.seq_num }}
{%-                                 endfor %}
{%-                             endfor %}
{%-                         endfor %}
{%-                     endfor %}
{%-                 endfor %}
{%-             endfor %}
{%-         endif %}
{%-     endif %}
{%- endif %}