{%- if filetype_loop == 0 %}Node Label,Node ID,Device Type,Device Series,Device Family,Platform ID,Node IP,MAC Address,Software Version,Role,Role Source,Fabric Role,Parent Node ID,Greyout,Link ID,Link Source,Link Target,Link Status,Link Greyout,Start Port Name,Start Port ID,Start Port Speed,End Port Name,End Port ID,End Port Speed
{%-     for node in routingTopology.nodes %}
{{ node.label }},{{ node.id }},{{ node.deviceType }},{{ node.deviceSeries }},{{ node.family }},{{ node.platformId }},{{ node.ip }},{{ node.additionalInfo.macAddress }},{{ node.softwareVersion }},{{ node.role }},{{ node.roleSource }},{%- for role in node.additionalInfo.fabricRoles %}{{ role }} {% endfor %},{{ node.customParam.parentNodeId }},{{ node.greyOut }},N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A
{%-     endfor %}
{%-     for link in routingTopology.links %}
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,{{ link.id }},{{ link.source }},{{ link.target }},{{ link.linkStatus }},{{ link.greyOut }},{{ link.startPortName }},{{ link.startPortID }},{{ link.startPortSpeed }},{{ link.endPortName }},{{ link.endPortID }},{{ link.endPortSpeed }}
{%-     endfor %}
{%- else %}
{%-     if filetype_loop == 1 %}
# DNAC {{ protocol }} Topology
| Node Label | Node ID | Device Type | Device Series | Device Family | Platform ID | Node IP | MAC Address | Software Version | Role | Role Source | Fabric Role | Parent Node ID | Greyout | Link ID | Link Source | Link Target | Link Status | Link Greyout | Start Port Name | Start Port ID | Start Port Speed | End Port Name | End Port ID | End Port Speed  |
| ---------- | ------- | ----------- | ------------- | ------------- | ----------- | ------- | ----------- | ---------------- | ---- | ----------- | ----------- | -------------- | ------- | ------- | ----------- | ----------- | ----------- | ------------ | --------------- | ------------- | ---------------- | ------------- | ----------- | --------------- |
{%-     for node in routingTopology.nodes %}
| {{ node.label }} | {{ node.id }} | {{ node.deviceType }} | {{ node.deviceSeries }} | {{ node.family }} | {{ node.platformId }} | {{ node.ip }} | {{ node.additionalInfo.macAddress }} | {{ node.softwareVersion }} | {{ node.role }} | {{ node.roleSource }} | {%- for role in node.additionalInfo.fabricRoles %}{{ role }} {% endfor %} | {{ node.customParam.parentNodeId }} | {{ node.greyOut }} | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A |
{%-     endfor %}
{%-     for link in routingTopology.links %}
| 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 | {{ link.id }} | {{ link.source }} | {{ link.target }} | {{ link.linkStatus }} | {{ link.greyOut }} | {{ link.startPortName }} | {{ link.startPortID }} | {{ link.startPortSpeed }} | {{ link.endPortName }} | {{ link.endPortID }} | {{ link.endPortSpeed }} |
{%-     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>DNAC {{ protocol }} Topology</h1>
<table id = "routing">
  <thead>
    <tr>
      <th>Node Label</th>
      <th>Node ID</th>
      <th>Device Type</th>
      <th>Device Series</th>
      <th>Device Family</th>
      <th>Platform ID</th>
      <th>Node IP</th>
      <th>MAC Address</th>
      <th>Software Version</th>
      <th>Role</th>
      <th>Role Source</th>
      <th>Fabric Role</th>
      <th>Parent Node ID</th>
      <th>Greyout</th>
      <th>Link ID</th>
      <th>Link Source</th>
      <th>Link Target</th>
      <th>Link Status</th>
      <th>Link Greyout</th>
      <th>Start Port Name</th>
      <th>Start Port ID</th>
      <th>Start Port Speed</th>
      <th>End Port Name</th>
      <th>End Port ID</th>
      <th>End Port Speed</th>
    </tr>
  </thead>
  <tbody>
{%-     for node in routingTopology.nodes %}
<tr>
    <td>{{ node.label }}</td>
    <td>{{ node.id }}</td>
    <td>{{ node.deviceType }}</td>
    <td>{{ node.deviceSeries }}</td>
    <td>{{ node.family }}</td>
    <td>{{ node.platformId }}</td>
    <td>{{ node.ip }}</td>
    <td>{{ node.additionalInfo.macAddress }}</td>
    <td>{{ node.softwareVersion }}</td>
    <td>{{ node.role }}</td>
    <td>{{ node.roleSource }}</td>
    <td>{%- for role in node.additionalInfo.fabricRoles %}{{ role }} {% endfor %}</td>
    <td>{{ node.customParam.parentNodeId }}</td>
    <td>{{ node.greyOut }}</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>
{%-         endfor %}
{%-         for link in routingTopology.links %}
<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>{{ link.id }}</td>
    <td>{{ link.source }}</td>
    <td>{{ link.target }}</td>
    <td>{{ link.linkStatus }}</td>
    <td>{{ link.greyOut }}</td>
    <td>{{ link.startPortName }}</td>
    <td>{{ link.startPortID }}</td>
    <td>{{ link.startPortSpeed }}</td>
    <td>{{ link.endPortName }}</td>
    <td>{{ link.endPortID }}</td>
    <td>{{ link.endPortSpeed }}</td>
  </tr>
{%-         endfor %}
  </tbody>
</table>
<script type = "text/javascript">
  $(document).ready(function(){
    $('#routing thead tr')
    .clone(true)
    .addClass('filters')
    .appendTo('#routing thead');

    var table = $('#routing').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 %}
# {{ protocol }}
## Nodes
{%- for node in routingTopology.nodes %}
### {{ node.label }}
#### ID: {{ node.id }}
#### Platform
##### Type: {{ node.deviceType }}
##### Series: {{ node.deviceSeries }}
##### Family: {{ node.family }}
##### ID: {{ node.platformId }}
#### Identity 
##### IP: {{ node.ip }}
##### MAC: {{ node.additionalInfo.macAddress }}
##### Software Version: {{ node.softwareVersion }}
##### Role: {{ node.role }}
##### Role Source: {{ node.roleSource }}
{%-     for role in node.additionalInfo.fabricRoles %}
##### Fabric Role: {{ role }}
{%-     endfor %}
##### Parent Node ID: {{ node.customParam.parentNodeId }}
#### Greyout: {{ node.greyOut }}
{%- endfor %}
## Links
{%- for link in routingTopology.links %}
### ID: {{ link.id }}
#### Source: {{ link.source }}
#### Target: {{ link.target }}
#### Status: {{ link.linkStatus }}
#### Greyout: {{ link.greyOut }}
#### Start Port
##### {{ link.startPortName }}
###### ID: {{ link.startPortID }}
###### Speed: {{ link.startPortSpeed }}
#### End Port
##### {{ link.endPortName }}
###### ID: {{ link.endPortID }}
###### Speed: {{ link.endPortSpeed }}
{%- endfor %}
{%-         endif %}
{%-     endif %}
{%- endif %}