{% if filetype_loop == 0 %}VRF,Address Family,Instance,Area,Interface,Name,Interface Type,Passive,IP Address,Router ID,,BFD,Cost,Dead Interval,Enabled,Graceful Restart Type,GR Helper,Hello Interval,Hello Timer,Index,Retransmit Interval,State,Neighbor Count,Transmit Delay,Wait Interval
{%-     for vrf in to_parse_ip_ospf_interface %}
{%-         for address_family in to_parse_ip_ospf_interface[vrf].address_family %}
{%-             for instance in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance %}
{%-                 for area in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas %}
{%-                     for interface in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces %}
{%-                         for graceful_restart in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].graceful_restart %}
{{ vrf }},{{ address_family }},{{ instance }},{{ area }},{{ interface }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].name }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].interface_type }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].passive }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].ip_address }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].router_id }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].bfd.enable }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].cost }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].dead_interval }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].enable }},{{ graceful_restart }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].graceful_restart[graceful_restart].helper }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].hello_interval }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].hello_timer }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].index }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].retransmit_interval }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].state }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].statistics.nbr_count }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].transmit_delay }},{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].wait_interval }}
{%-                         endfor %}
{%-                     endfor %}
{%-                 endfor %}
{%-             endfor %}
{%-         endfor %}
{%-     endfor %}
{%- else %}
{%-     if filetype_loop == 1 %}
# Show IP OPSF Interface
| VRF | Address Family | Instance | Area | Interface | Name | Interface Type | Passive | IP Address | Router ID | BFD | Cost | Dead Interval | Enabled | Graceful Restart Type | GR Helper | Hello Interval | Hello Timer | Index | Retransmit Interval | State | Neighbor Count | Transmit Delay | Wait Interval |
| --- | -------------- | -------- | ---- | --------- | ---- | -------------- | ------- | ---------- | --------- | --- | ---- | ------------- | ------- | --------------------- | --------- | -------------- | ----------- | ----- | ------------------- | ----- | -------------- | -------------- | ------------- |
{%-         for vrf in to_parse_ip_ospf_interface %}
{%-             for address_family in to_parse_ip_ospf_interface[vrf].address_family %}
{%-                 for instance in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance %}
{%-                     for area in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas %}
{%-                         for interface in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces %}
{%-                             for graceful_restart in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].graceful_restart %}
| {{ vrf }} | {{ address_family }} | {{ instance }} | {{ area }} | {{ interface }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].name }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].interface_type }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].passive }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].ip_address }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].router_id }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].bfd.enable }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].cost }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].dead_interval }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].enable }} | {{ graceful_restart }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].graceful_restart[graceful_restart].helper }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].hello_interval }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].hello_timer }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].index }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].retransmit_interval }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].state }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].statistics.nbr_count }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].transmit_delay }} | {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].wait_interval }} |
{%-                             endfor %}
{%-                         endfor %}
{%-                     endfor %}
{%-                 endfor %}
{%-             endfor %}
{%-         endfor %}
{%-     else %}
{%-         if filetype_loop == 2 %}
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/dataTables.buttons.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/buttons.html5.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/buttons.print.min.js"></script>
    <script src="https://cdn.datatables.net/colreorder/1.5.4/js/dataTables.colReorder.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/buttons.colVis.min.js"></script>
    <script src="https://cdn.datatables.net/keytable/2.6.4/js/dataTables.keyTable.min.js"></script>
    <script src="https://cdn.datatables.net/select/1.3.3/js/dataTables.select.min.js"></script>
    <script src="https://cdn.datatables.net/fixedheader/3.1.9/js/dataTables.fixedHeader.min.js"></script>
    <link rel="stylesheet" href="https://cdn.datatables.net/fixedheader/3.1.9/css/fixedHeader.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/keytable/2.6.4/css/keyTable.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css">
</head>
<body>
<h1>Show IP OSPF Interface</h1>
<table id = "ospf">
  <thead>
  <tr>
    <th>VRF</th>
    <th>Address Family</th>
    <th>Instance</th>
    <th>Area</th>
    <th>Interface</th>
    <th>Name</th>
    <th>Interface Type</th>
    <th>Passive</th>
    <th>IP Address</th>
    <th>Router ID</th>
    <th>BFD</th>
    <th>Cost</th>
    <th>Dead Interval</th>
    <th>Enabled</th>
    <th>Graceful Restart Type</th>
    <th>GR Helper</th>
    <th>Hello Interval</th>
    <th>Hello Timer</th>
    <th>Index</th>
    <th>Retransmit Interval</th>
    <th>State</th>
    <th>Neighbor Count</th>
    <th>Transmit Delay</th>
    <th>Wait Interval</th>
  </tr>
  </thead>
  <tbody>
{%-             for vrf in to_parse_ip_ospf_interface %}
{%-                 for address_family in to_parse_ip_ospf_interface[vrf].address_family %}
{%-                     for instance in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance %}
{%-                         for area in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas %}
{%-                             for interface in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces %}
{%-                                 for graceful_restart in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].graceful_restart %}
<tr>
    <td>{{ vrf }}</td>
    <td>{{ address_family }}</td>
    <td>{{ instance }}</td>
    <td>{{ area }}</td>
    <td>{{ interface }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].name }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].interface_type }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].passive }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].ip_address }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].router_id }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].bfd.enable }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].cost }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].dead_interval }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].enable }}</td>
    <td>{{ graceful_restart }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].graceful_restart[graceful_restart].helper }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].hello_interval }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].hello_timer }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].index }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].retransmit_interval }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].state }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].statistics.nbr_count }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].transmit_delay }}</td>
    <td>{{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].wait_interval }}</td>
  </tr>
{%-                                 endfor %}
{%-                             endfor %}
{%-                         endfor %}
{%-                     endfor %}
{%-                 endfor %}
{%-             endfor %}
  </tbody>
</table>
<script type = "text/javascript">
  $(document).ready(function(){
    $('#ospf thead tr')
    .clone(true)
    .addClass('filters')
    .appendTo('#ospf thead');

    var table = $('#ospf').DataTable({
        keys: true,
        dom: 'Bfrtip',
        lengthMenu: [
            [ 10, 25, 50, -1 ],
            [ '10 rows', '25 rows', '50 rows', 'Show all' ]
        ],
        buttons: [
        'pageLength','colvis','copy', 'csv', 'excel', 'pdf', 'print'
        ],
        colReorder: true,
        select: true,            
        orderCellsTop: true,
        fixedHeader: true,
        initComplete: function () {
        var api = this.api();

        // For each column
        api
            .columns()
            .eq(0)
            .each(function (colIdx) {
                // Set the header cell to contain the input element
                var cell = $('.filters th').eq(
                    $(api.column(colIdx).header()).index()
                );
                var title = $(cell).text();
                $(cell).html('<input type="text" placeholder="' + title + '" />');

                // On every keypress in this input
                $(
                    'input',
                    $('.filters th').eq($(api.column(colIdx).header()).index())
                )
                    .off('keyup change')
                    .on('keyup change', function (e) {
                        e.stopPropagation();

                        // Get the search value
                        $(this).attr('title', $(this).val());
                        var regexr = '({search})'; //$(this).parents('th').find('select').val();

                        var cursorPosition = this.selectionStart;
                        // Search the column for that value
                        api
                            .column(colIdx)
                            .search(
                                this.value != ''
                                    ? regexr.replace('{search}', '(((' + this.value + ')))')
                                    : '',
                                this.value != '',
                                this.value == ''
                            )
                            .draw();

                        $(this)
                            .focus()[0]
                            .setSelectionRange(cursorPosition, cursorPosition);
                    });
            });
    },
});
});        
</script>
</body></html>
{%-         else %}
# Show IP OSPF Interface
{%-             for vrf in to_parse_ip_ospf_interface %}
{%-                 for address_family in to_parse_ip_ospf_interface[vrf].address_family %}
## {{ vrf }} - {{ address_family }}
{%-                     for instance in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance %}
### Instance: {{ instance }}
{%-                         for area in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas %}
#### Area: {{ area }}
{%-                             for interface in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces %}
##### {{ interface }}</td>
###### Name: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].name }}</td>
###### Type: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].interface_type }}</td>
###### Passive: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].passive }}</td>
###### IP Address: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].ip_address }}</td>
###### Router ID: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].router_id }}</td>
###### BFD Enable: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].bfd.enable }}</td>
###### Cost: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].cost }}</td>
###### Dead Interval: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].dead_interval }}</td>
###### Enabled: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].enable }}</td>
###### Hello Interval: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].hello_interval }}</td>
###### Hello Timer: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].hello_timer }}</td>
###### Index: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].index }}</td>
###### Retransmit Interval: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].retransmit_interval }}</td>
###### State: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].state }}</td>
###### Neighbor Count: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].statistics.nbr_count }}</td>
###### Transmit Delay: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].transmit_delay }}</td>
###### {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].wait_interval }}</td>
{%-                                 for graceful_restart in to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].graceful_restart %}
###### Graceful Restart: {{ graceful_restart }}</td>
###### Graceful Helper: {{ to_parse_ip_ospf_interface[vrf].address_family[address_family].instance[instance].areas[area].interfaces[interface].graceful_restart[graceful_restart].helper }}</td>
{%-                                 endfor %}
{%-                             endfor %}
{%-                         endfor %}
{%-                     endfor %}
{%-                 endfor %}
{%-             endfor %}
{%-         endif %}
{%-     endif %}
{%- endif %}