{% load environment %}

<script>

VALID_ENVIRONMENTS = {{ environments_json }};

</script>

<section class="drillenv {% if hasenv == 'empty' %}empty{% endif %}">
  {% if hasenv != 'empty' %}
    <h3 class="sectionhead">Set your environment</h3>
    <form id="runtests-environment-form" method="POST" action="{{ run|set_environment_url }}">
      {% csrf_token %}
      {{ form.non_field_errors }}
      {% for field in form %}
        {% include "forms/_field.html" with field=field %}
      {% endfor %}
      <div class="form-actions">
        <button type="submit">run tests in {{ run }}!</button>
      </div>
    </form>
  {% endif %}
</section>
{% load environment %}

{% if environments_json %}
<script>
VALID_ENVIRONMENTS = {{ environments_json }};
</script>
{% endif %}

<section class="drillenv {% if not form %}empty{% endif %}">
  {% if form %}
    <h3 class="sectionhead">Set your environment</h3>
    <form id="runtests-environment-form" method="POST" action="{{ run|set_environment_url }}">
      {% csrf_token %}
      {{ form.non_field_errors }}
      {% for field in form %}
        {% include "forms/_field.html" with field=field %}
      {% endfor %}
      <div class="form-actions">
        <button type="submit">run tests in {{ run }}!</button>
      </div>
    </form>
  {% endif %}
</section>

Clean up environment form template; avoid JS error.
Clean up environment form template; avoid JS error.
