{% if filetype_loop == 0 %}Device Type,Chassis,Serial Number,Uptime,Directory,Total Disk,Used Disk,Free Disk,Image,Main Memory,OS,Version,Slot Name,Slot Serial Number,Slot State,Redundancy State,RP Boot Image,RP Uptime,Virtual Device Name,Virtual Device Status,Virtual Interface,Virtual Interface Type,Virtual Interface Status
{{ to_parse_platform.rtr_type | default("N/A") }},{{ to_parse_platform.chassis | default("N/A") }},{{ to_parse_platform.chassis_sn | default("N/A") }},{{ to_parse_platform.rp_uptime | default("N/A") }},{{ to_parse_platform.dir | default("N/A") }},{{ to_parse_platform.disk_total_space | default("N/A") }},{{ to_parse_platform.disk_used_space | default("N/A") }},{{ to_parse_platform.disk_free_space | default("N/A") }},{{ to_parse_platform.image | default("N/A") }},{{ to_parse_platform.main_mem | default("N/A") }},{{ to_parse_platform.os | default("N/A") }},{{ to_parse_platform.version | default("N/A") }},N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A
{%-     for slot in to_parse_platform.slot %}
{%-         for sub_slot in to_parse_platform.slot[slot] %}
N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,{{ to_parse_platform.slot[slot][sub_slot].name | default("N/A") }},{{ to_parse_platform.slot[slot][sub_slot].sn | default("N/A") }},{{ to_parse_platform.slot[slot][sub_slot].state | default("N/A") }},{% if slot == "rp" %}{{ to_parse_platform.slot[slot][sub_slot].redundancy_state | default("N/A") }},{{ to_parse_platform.slot[slot][sub_slot].rp_boot_image | default("N/A") }},{{ to_parse_platform.slot[slot][sub_slot].rp_uptime | default("N/A") }},{% else %}N/A,N/A,N/A,{% endif %}N/A,N/A,N/A,N/A,N/A
{%          endfor %}
{%-     endfor %}
{%-     for virtual_device in to_parse_platform.virtual_device %}
{%-         for interface in to_parse_platform.virtual_device[virtual_device].membership %}
N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,{{ to_parse_platform.virtual_device[virtual_device].vd_name | default("N/A") }},{{ to_parse_platform.virtual_device[virtual_device].vd_status | default("N/A") }},{{ interface }},{{ to_parse_platform.virtual_device[virtual_device].membership[interface].type | default("N/A") }},{{ to_parse_platform.virtual_device[virtual_device].membership[interface].status | default("N/A") }}
{%-         endfor %}
{%-     endfor %}
{%- else %}
{%     if filetype_loop == 1 %}
# Learn Platform
| Device Type | Chassis | Serial Number | Uptime | Directory | Total Disk | Used Disk | Free Disk | Image | Main Memory | OS | Version | Slot Name | Slot Serial Number | Slot State | Redundancy State | RP Boot Image | RP Uptime | Virtual Device Name | Virtual Device Status | Virtual Interface | Virtual Interface Type | Virtual Interface Status |
| ----------- | ------- | ------------- | ------ | --------- | ---------- | --------- | --------- | ----- | ----------- | -- | ------- | --------- | ------------------ | ---------- | ---------------- | ------------- | --------- | ------------------- | --------------------- | ----------------- | ---------------------- | ------------------------ |
| {{ to_parse_platform.rtr_type | default("N/A") }} | {{ to_parse_platform.chassis | default("N/A") }} | {{ to_parse_platform.chassis_sn | default("N/A") }} | {{ to_parse_platform.rp_uptime | default("N/A") }} | {{ to_parse_platform.dir | default("N/A") }} | {{ to_parse_platform.disk_total_space | default("N/A") }} | {{ to_parse_platform.disk_used_space | default("N/A") }} | {{ to_parse_platform.disk_free_space | default("N/A") }} | {{ to_parse_platform.image | default("N/A") }} | {{ to_parse_platform.main_mem | default("N/A") }} | {{ to_parse_platform.os | default("N/A") }} | {{ to_parse_platform.version | default("N/A") }} | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A |
{%-        for slot in to_parse_platform.slot %}
{%-            for sub_slot in to_parse_platform.slot[slot] %}
| N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | {{ to_parse_platform.slot[slot][sub_slot].name | default("N/A") }} | {{ to_parse_platform.slot[slot][sub_slot].sn | default("N/A") }} | {{ to_parse_platform.slot[slot][sub_slot].state | default("N/A") }} | {% if slot == "rp" %}{{ to_parse_platform.slot[slot][sub_slot].redundancy_state | default("N/A") }} | {{ to_parse_platform.slot[slot][sub_slot].rp_boot_image | default("N/A") }} | {{ to_parse_platform.slot[slot][sub_slot].rp_uptime | default("N/A") }} | {% else %}N/A | N/A | N/A | {% endif %}N/A | N/A | N/A | N/A | N/A |
{%-            endfor %}
{%-        endfor %}
{%-        for virtual_device in to_parse_platform.virtual_device %}
{%-            for interface in to_parse_platform.virtual_device[virtual_device].membership %}
| N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | {{ to_parse_platform.virtual_device[virtual_device].vd_name | default("N/A") }} | {{ to_parse_platform.virtual_device[virtual_device].vd_status | default("N/A") }} | {{ interface }} | {{ to_parse_platform.virtual_device[virtual_device].membership[interface].type | default("N/A") }} | {{ to_parse_platform.virtual_device[virtual_device].membership[interface].status | default("N/A") }} |
{%-            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>Learn Platform</h1>
<table id = "platform">
  <thead>
  <tr>
    <th>Device Type</th>
    <th>Chassis</th>
    <th>Serial Number</th>
    <th>Uptime</th>
    <th>Directory</th>
    <th>Total Disk</th>
    <th>Used Disk</th>
    <th>Free Disk</th>
    <th>Image</th>
    <th>Main Memory</th>
    <th>OS</th>
    <th>Version</th>
    <th>Slot Name</th>
    <th>Slot Serial Number</th>
    <th>Slot State</th>
    <th>Redundancy State</th>
    <th>RP Boot Image</th>
    <th>RP Uptime</th>
    <th>Virtual Device Name</th>
    <th>Virtual Device Status</th>
    <th>Virtual Interface</th>
    <th>Virtual Interface Type</th>
    <th>Virtual Interface Status</th>
  </tr>
  </thead>
  <tbody>
  <tr>
    <td>{{ to_parse_platform.rtr_type | default("N/A") }}</td>
    <td>{{ to_parse_platform.chassis | default("N/A") }}</td>
    <td>{{ to_parse_platform.chassis_sn | default("N/A") }}</td>
    <td>{{ to_parse_platform.rp_uptime | default("N/A") }}</td>
    <td>{{ to_parse_platform.dir | default("N/A") }}</td>
    <td>{{ to_parse_platform.disk_total_space | default("N/A") }}</td>
    <td>{{ to_parse_platform.disk_used_space | default("N/A") }}</td>
    <td>{{ to_parse_platform.disk_free_space | default("N/A") }}</td>
    <td>{{ to_parse_platform.image | default("N/A") }}</td>
    <td>{{ to_parse_platform.main_mem | default("N/A") }}</td>
    <td>{{ to_parse_platform.os | default("N/A") }}</td>
    <td>{{ to_parse_platform.version | default("N/A") }}</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
  </tr>
{%-         for slot in to_parse_platform.slot %}
{%-             for sub_slot in to_parse_platform.slot[slot] %}
<tr>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>{{ to_parse_platform.slot[slot][sub_slot].name | default("N/A") }}</td>
    <td>{{ to_parse_platform.slot[slot][sub_slot].sn | default("N/A") }}</td>
    <td>{{ to_parse_platform.slot[slot][sub_slot].state | default("N/A") }}</td>{% if slot == "rp" %}
    <td>{{ to_parse_platform.slot[slot][sub_slot].redundancy_state | default("N/A") }}</td>
    <td>{{ to_parse_platform.slot[slot][sub_slot].rp_boot_image | default("N/A") }}</td>
    <td>{{ to_parse_platform.slot[slot][sub_slot].rp_uptime | default("N/A") }}</td>{% else %}
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>{% endif %}
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
  </tr>
{%-             endfor %}
{%-         endfor %}
{%-         for virtual_device in to_parse_platform.virtual_device %}
{%-             for interface in to_parse_platform.virtual_device[virtual_device].membership %}
<tr>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>{{ to_parse_platform.virtual_device[virtual_device].vd_name | default("N/A") }}</td>
    <td>{{ to_parse_platform.virtual_device[virtual_device].vd_status | default("N/A") }}</td>
    <td>{{ interface }}</td>
    <td>{{ to_parse_platform.virtual_device[virtual_device].membership[interface].type | default("N/A") }}</td>
    <td>{{ to_parse_platform.virtual_device[virtual_device].membership[interface].status | default("N/A") }}</td>
  </tr>
{%-             endfor %}
{%-         endfor %}
  </tbody>  
</table>
<script type = "text/javascript">
  $(document).ready(function(){
    $('#platform thead tr')
    .clone(true)
    .addClass('filters')
    .appendTo('#platform thead');

    var table = $('#platform').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 %}
# Learn Platform
## Router Type: {{ to_parse_platform.rtr_type | default("N/A") }}
## Chassis
### {{ to_parse_platform.chassis | default("N/A") }}
### Serial Number: {{ to_parse_platform.chassis_sn | default("N/A") }}
## RP Uptime: {{ to_parse_platform.rp_uptime | default("N/A") }}
## Directory: {{ to_parse_platform.dir | default("N/A") }}
## Disk Space
### Total: {{ to_parse_platform.disk_total_space | default("N/A") }}
### Used: {{ to_parse_platform.disk_used_space | default("N/A") }}
### Free: {{ to_parse_platform.disk_free_space | default("N/A") }}
## Image: {{ to_parse_platform.image | default("N/A") }}
## Main Memory: {{ to_parse_platform.main_mem | default("N/A") }}
## Operating System: {{ to_parse_platform.os | default("N/A") }}
## Version: {{ to_parse_platform.version | default("N/A") }}
## Slots
{%-         for slot in to_parse_platform.slot %}
{%-             for sub_slot in to_parse_platform.slot[slot] %}
### {{ to_parse_platform.slot[slot][sub_slot].name | default("N/A") }}
#### Serial Number: {{ to_parse_platform.slot[slot][sub_slot].sn | default("N/A") }}
#### State: {{ to_parse_platform.slot[slot][sub_slot].state | default("N/A") }}{% if slot == "rp" %}
#### Redundancy State: {{ to_parse_platform.slot[slot][sub_slot].redundancy_state | default("N/A") }}
#### RP
##### Boot Image: {{ to_parse_platform.slot[slot][sub_slot].rp_boot_image | default("N/A") }}
##### Uptime: {{ to_parse_platform.slot[slot][sub_slot].rp_uptime | default("N/A") }}{% endif %}
{%-             endfor %}
{%-         endfor %}
## Virtual Devices
{%-         for virtual_device in to_parse_platform.virtual_device %}
### {{ to_parse_platform.virtual_device[virtual_device].vd_name | default("N/A") }}
#### Status: {{ to_parse_platform.virtual_device[virtual_device].vd_status | default("N/A") }}
#### Interfaces
{%-             for interface in to_parse_platform.virtual_device[virtual_device].membership %}
##### {{ interface }}
###### Type: {{ to_parse_platform.virtual_device[virtual_device].membership[interface].type | default("N/A") }}
###### Status: {{ to_parse_platform.virtual_device[virtual_device].membership[interface].status | default("N/A") }}
{%-             endfor %}
{%-         endfor %}
{%-        endif %}
{%-    endif %}
{%- endif %}