{% if not included %}
{% extends 'index.html' %}
{% endif %}

{% set included = True %}

{% block content%}

{% for d in data %}

<fieldset data-template="{{d.template}}",
          data-instance="{{loop.index}}">
  
  <h5>
    {% if show_controls %}
    <small class="text-muted">{{loop.index}}</small>
    {% endif %}
    {{d.template}}
  </h5>
  
  {% for k,v in d.params.items() %}
  <div class="row mb-2">
    <label class="col-2 col-form-label" for="{{d.template}}-{{k}}">{{k}}</label>
    <div class="col">
      <input class="form-control col"
             id="{{d.template}}-{{k}}"
             name="{{k}}"
             data-{{k}}="{{v}}"
             value="{{v}}"
             {% if v is number %}
             type="number"
             {% elif v is boolean %}
             type="checkbox"
             {% else %}
             type="text"
             {% endif %}
             >
    </div>
    <!-- {% if v is number or v is boolean or v is string %} -->
    <!-- {% else %} -->
    <!-- {% for x in v %} -->
    <!-- <div class="col" id="{{d.template}}-{{k}}"> -->
    <!--   <input class="form-control col" id="{{x}}" value="{{x}}" name="{{x}}"> -->
    <!-- </div> -->
    <!-- {% endfor %} -->
    <!-- {% endif %}                  -->
  </div>
  {% endfor %}

  {% if show_controls %}
  <button class="col-2 me-2 btn btn-secondary" type="submit"
          data-button="delete-template"
          data-instance="{{loop.index}}">Delete</button>
  {% endif %}

</fieldset>
{% endfor %}


{% endblock content %}
