{% assert view_object.error is defined %}

<sdoc-form search
 {% if (view_object.error is none) and (view_object.search_results|length > 0) %}success{% endif %}
>

  <form
    action="/search"
    method="GET"
  >
      <input
        type="text"
        value="{{ view_object.search_value }}"
        placeholder="Enter search query here"
        id="q"
        name="q"
      />
      {% include "components/button/search.jinja" %}
  </form>

{%- if view_object.search_value|length > 0 -%}
  {%- if view_object.error is none -%}
    {%- if view_object.search_results|length == 0 -%}
      <div class="sdoc-form-success">Nothing matching the query was found.</div>
    {%- elif view_object.search_results|length > 0 -%}
      <div class="sdoc-form-success">Found <b>{{ view_object.search_results|length }}</b> results.</div>
    {%- endif -%}
  {%- else -%}
      <div class="sdoc-form-error">{{ view_object.error }}</div>
  {%- endif -%}
  <a class="sdoc-form-reset" href="{{ view_object.render_url('search') }}">Clear query</a>
{%- endif -%}
</sdoc-form>
