{%- if filetype_loop == 0 %}Project,Template Name,Template Description,Tag Name,Tag ID,Author,Product Family,Software Type,Display NameParameter ID,Data Type,Parameter Description,Instructions Text,Default Value,Required,Not Param,Param Array,Group,Order,Custom Order
{%-     if template.tags is not none %}
{%-         for tag in template.tags %}
{%-             for type in template.deviceTypes %}
{%-                 for param in template.templateParams %}
{{ project }},{{ template.name }},{{ template.description }},{{ tag.name }},{{ tag.id }},{{ template.author }},{{ type.productFamily }},{{ template.softwareType }},{{ param.displayName }},{{ param.id }},{{ param.dataType }},{{ param.description }},{{ param.instructionText }},{{ param.defaultValue }},{{ param.required }},{{ param.notParam }},{{ param.paramArray }},{{ param.group }},{{ param.order }},{{ param.customOrder }}
{%-                 endfor %}
{%-             endfor %}
{%-         endfor %}
{%-     else %}
{%-         for type in template.deviceTypes %}
{%-             for param in template.templateParams %}
{{ project }},{{ template.name }},{{ template.description }},No Tags,no Tags,{{ template.author }},{{ type.productFamily }},{{ template.softwareType }},{{ param.displayName }},{{ param.id }},{{ param.dataType }},{{ param.description }},{{ param.instructionText }},{{ param.defaultValue }},{{ param.required }},{{ param.notParam }},{{ param.paramArray }},{{ param.group }},{{ param.order }},{{ param.customOrder }}
{%-             endfor %}
{%-         endfor %}
{%-     endif %}
{%- else %}
{%-     if filetype_loop == 1 %}
# DNAC Templates
| Project | Template Name | Template Description | Tag Name | Tag ID | Author | Product Family | Software Type | Display NameParameter ID | Data Type | Parameter Description | Instructions Text | Default Value | Required | Not Param | Param Array | Group | Order | Custom Order |
| ------- | ------------- | -------------------- | -------- | ------ | ------ | -------------- | ------------- | ------------------------ | --------- | --------------------- | ----------------- | ------------- | -------- | --------- | ----------- | ----- | ----- | ------------ |
{%-     if template.tags is not none %}
{%-         for tag in template.tags %}
{%-             for type in template.deviceTypes %}
{%-                 for param in template.templateParams %}
| {{ project }} | {{ template.name }} | {{ template.description }} | {{ tag.name }} | {{ tag.id }} | {{ template.author }} | {{ type.productFamily }} | {{ template.softwareType }} | {{ param.displayName }} | {{ param.id }} | {{ param.dataType }} | {{ param.description }} | {{ param.instructionText }} | {{ param.defaultValue }} | {{ param.required }} | {{ param.notParam }} | {{ param.paramArray }} | {{ param.group }} | {{ param.order }} | {{ param.customOrder }} |
{%-                 endfor %}
{%-             endfor %}
{%-         endfor %}
{%-     else %}
{%-         for type in template.deviceTypes %}
{%-             for param in template.templateParams %}
| {{ project }} | {{ template.name }} | {{ template.description }} | No Tags | no Tags | {{ template.author }} | {{ type.productFamily }} | {{ template.softwareType }} | {{ param.displayName }} | {{ param.id }} | {{ param.dataType }} | {{ param.description }} | {{ param.instructionText }} | {{ param.defaultValue }} | {{ param.required }} | {{ param.notParam }} | {{ param.paramArray }} | {{ param.group }} | {{ param.order }} | {{ param.customOrder }} |
{%-             endfor %}
{%-         endfor %}
{%-     endif %}
{%-     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 Templates</h1>
<table id ="templates">
  <thead>
    <tr>
      <th>Project</th>
      <th>Template Name</th>
      <th>Template Description</th>
      <th>Tag Name</th>
      <th>Tag ID</th>
      <th>Author</th>
      <th>Product Family</th>
      <th>Software Type</th>
      <th>Display NameParameter ID</th>
      <th>Data Type</th>
      <th>Parameter Description</th>
      <th>Instructions Text</th>
      <th>Default Value</th>
      <th>Required</th>
      <th>Not Param</th>
      <th>Param Array</th>
      <th>Group</th>
      <th>Order</th>
      <th>Custom Order</th>
    </tr>
  </thead>
  <tbody>
{%-     if template.tags is not none %}
{%-         for tag in template.tags %}
{%-             for type in template.deviceTypes %}
{%-                 for param in template.templateParams %}
  {%                if loop.index is divisibleby 2 %}
  <tr style='background-color:#ddd'>
  {%-               endif % %}
    <td>{{ project }}</td>
    <td>{{ template.name }}</td>
    <td>{{ template.description }}</td>
    <td>{{ tag.name }}</td>
    <td>{{ tag.id }}</td>
    <td>{{ template.author }}</td>
    <td>{{ type.productFamily }}</td>
    <td>{{ template.softwareType }}</td>
    <td>{{ param.displayName }}</td>
    <td>{{ param.id }}</td>
    <td>{{ param.dataType }}</td>
    <td>{{ param.description }}</td>
    <td>{{ param.instructionText }}</td>
    <td>{{ param.defaultValue }}</td>
    <td>{{ param.required }}</td>
    <td>{{ param.notParam }}</td>
    <td>{{ param.paramArray }}</td>
    <td>{{ param.group }}</td>
    <td>{{ param.order }}</td>
    <td>{{ param.customOrder }}</td>
  </tr>
{%-                 endfor %}
{%-             endfor %}
{%-         endfor %}
{%-     else %}
{%-         for type in template.deviceTypes %}
{%-             for param in template.templateParams %}
  {%                if loop.index is divisibleby 2 %}
  <tr style='background-color:#ddd'>
  {%-               endif % %}
    <td>{{ project }}</td>
    <td>{{ template.name }}</td>
    <td>{{ template.description }}</td>
    <td>No Tags</td>
    <td>No Tags</td>
    <td>{{ template.author }}</td>
    <td>{{ type.productFamily }}</td>
    <td>{{ template.softwareType }}</td>
    <td>{{ param.displayName }}</td>
    <td>{{ param.id }}</td>
    <td>{{ param.dataType }}</td>
    <td>{{ param.description }}</td>
    <td>{{ param.instructionText }}</td>
    <td>{{ param.defaultValue }}</td>
    <td>{{ param.required }}</td>
    <td>{{ param.notParam }}</td>
    <td>{{ param.paramArray }}</td>
    <td>{{ param.group }}</td>
    <td>{{ param.order }}</td>
    <td>{{ param.customOrder }}</td>
  </tr>
{%-             endfor %}
{%-         endfor %}
{%-     endif %}  
  </tbody>
</table>
<script type = "text/javascript">
  $(document).ready(function(){
    $('#templates thead tr')
    .clone(true)
    .addClass('filters')
    .appendTo('#templates thead');

    var table = $('#templates').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 %}
# {{ project }}
## Template
### {{ template.name }}
#### Description: {{ template.description }}
#### Tags
{%- for tag in template.tags %}
##### Name: {{ tag.name }}
##### ID: {{ tag.id }}
{%- endfor %}
#### Author: {{ template.author }}
#### Device Types
{%- for type in template.deviceTypes %}
##### Product Family: {{ type.productFamily }}
{%- endfor %}
#### Software Type: {{ template.softwareType }}
#### Parameters
{%- for param in template.templateParams %}
##### {{ param.displayName }}
###### ID: {{ param.id }}
###### Type: {{ param.dataType }}
###### Description: {{ param.description }}
###### Instructions: {{ param.instructionText }}
###### Default Value: {{ param.defaultValue }}
###### Required: {{ param.required }}
###### Not Param: {{ param.notParam }}
###### Param Array: {{ param.paramArray }}
###### Group: {{ param.group }}
###### Order: {{ param.order }}
###### Custom Order: {{ param.customOrder }}
{%- endfor %}
{%-         endif %}
{%-     endif %}
{%- endif %}