- content_for :breadcrumbs do
  %li.breadcrumb-item= link_to 'Crops', crops_path
  %li.breadcrumb-item.active= link_to 'Search', search_crops_path(term: @term)

- if @term
  - content_for :title, "Crops matching \"#{@term}\""
  %h1
    Crops matching "#{@term}"
    - if @crops
      %span.text-muted Found #{@crops.size} total
- else
  - content_for :title, "Crop search"
  %h1 Crop search

= bootstrap_form_tag(url: search_crops_path, method: :get, html: { id: 'crop-search'}, layout: :inline) do |f|
  = f.label :term, "Search crops:", class: 'sr-only'
  = f.text_field 'term', class: 'search-query input-medium',
                   placeholder: 'Search crops',
                   label: 'crop',
                   value: @term
  = f.submit "Search", class: 'btn btn-success'

- if @crops.empty?
  %h2 No results found
  %p
    Sorry, we couldn't find any crops that matched your search for "#{@term}".
  %p
    Try
    = link_to "browsing our crop database", crops_path
    instead.

- else
  = will_paginate @crops

  .index-cards
    - @crops.each do |crop|
      = render 'crops/thumbnail', crop: crop


  = will_paginate @crops
