{%- if filetype_loop == 0 %}Project Name,Project ID,Deletable,Template Name,Template ID,Composite,Language,Custom Parameter Order,Last Update Time,Last Version Time,Project Associated,Document Database
{%- for project in projects %}
{%-     for template in project.templates %}
{{ project.name }},{{ project.id }},{{ project.isDeletable }},{{ template.name }},{{ template.id }},{{ template.composite }},{{ template.language }},{{ template.customParamsOrder }},{{ template.lastUpdateTime }},{{ template.latestVersionTime }},{{ template.projectAssociated }},{{ template.documentDatabase }}
{%-     endfor %}
{%- endfor %}
{%- else %}
{%-     if filetype_loop == 1 %}
# DNAC Projects
| Project Name | Project ID | Deletable | Template Name | Template ID | Composite | Language | Custom Parameter Order | Last Update Time | Last Version Time | Project Associated | Document Database |
| ------------ | ---------- | --------- | ------------- | ----------- | --------- | -------- | ---------------------- | ---------------- | ----------------- | ------------------ | ----------------- |
{%- for project in projects %}
{%-     for template in project.templates %}
| {{ project.name }} | {{ project.id }} | {{ project.isDeletable }} | {{ template.name }} | {{ template.id }} | {{ template.composite }} | {{ template.language }} | {{ template.customParamsOrder }} | {{ template.lastUpdateTime }} | {{ template.latestVersionTime }} | {{ template.projectAssociated }} | {{ template.documentDatabase }} |
{%-     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>DNAC Projects</h1>
<table id = "projects">
  <thead>
    <tr>
      <th>Project Name</th>
      <th>Project ID</th>
      <th>Deletable</th>
      <th>Template Name</th>
      <th>Template ID</th>
      <th>Composite</th>
      <th>Language</th>
      <th>Custom Parameter Order</th>
      <th>Last Update Time</th>
      <th>Last Version Time</th>
      <th>Project Associated</th>
      <th>Document Database</th>
    </tr>
  </thead>
  <tbody>
{%- for project in projects %}
{%-     for template in project.templates %}
<tr>
    <td>{{ project.name }}</td>
    <td>{{ project.id }}</td>
    <td>{{ project.isDeletable }}</td>
    <td>{{ template.name }}</td>
    <td>{{ template.id }}</td>
    <td>{{ template.composite }}</td>
    <td>{{ template.language }}</td>
    <td>{{ template.customParamsOrder }}</td>
    <td>{{ template.lastUpdateTime }}</td>
    <td>{{ template.latestVersionTime }}</td>
    <td>{{ template.projectAssociated }}</td>
    <td>{{ template.documentDatabase }}</td>
  </tr>
{%-     endfor %}
{%- endfor %}
  </tbody>
</table>
<script type = "text/javascript">
  $(document).ready(function(){
    $('#projects thead tr')
    .clone(true)
    .addClass('filters')
    .appendTo('#projects thead');

    var table = $('#projects').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 %}
# {{ DNAC }}
## Project
{%- for project in projects %}
### {{ project.name }}
#### ID: {{ project.id }}
#### Deletable: {{ project.isDeletable }}
#### Templates
{%-     for template in project.templates %}
##### {{ template.name }}
###### ID: {{ template.id }}
###### Composite: {{ template.composite }}
###### Language: {{ template.language }}
###### Custom Parameter Order: {{ template.customParamsOrder }}
###### Last Update Time: {{ template.lastUpdateTime }}
###### Last Version Time: {{ template.latestVersionTime }}
###### Project Associated: {{ template.projectAssociated }}
###### Document Database: {{ template.documentDatabase }}
{%-     endfor %}
{%- endfor %}
{%-         endif %}
{%-     endif %}
{%- endif %}