<commit_before>module Filter
  class Builder::SearchField < Builder

    def self.render
      lambda do |attr, opts|
        attr  = opts[:is_scoped] ? attr : [attr, 'cont'].join('_')

        haml_tag :div, class: 'form-group' do
          value = opts[:value]
          if opts[:skip_button]
            haml_concat label(opts[:namespace], attr, opts[:title] || "Search #{attr.to_s.humanize}")
            haml_concat text_field(opts[:namespace], attr, value: value, class: 'form-control', placeholder: opts[:title] || "Search #{attr.to_s.humanize}")
          else
            haml_tag :div, class: 'input-group' do
              haml_concat text_field(opts[:namespace], attr, value: value, class: 'form-control', placeholder: opts[:title] || "Search #{attr.to_s.humanize}")
              haml_tag :span, class: 'input-group-btn' do
                haml_tag :button, type: 'button', class: 'btn btn-primary search' do
                  haml_tag :i, class: 'fa fa-search'
                  haml_concat 'Search'
                end
              end
            end
          end
        end
      end
    end

    def self.value(params, name)
      params[name] || params["#{name}_cont"]
    end

  end
end<commit_msg>Clean up<commit_after>module Filter
  class Builder::SearchField < Builder

    def self.render
      lambda do |attr, opts|
        attr  = opts[:is_scoped] ? attr : [attr, 'cont'].join('_')

        haml_tag :div, class: 'form-group' do
          input_options = { value: opts[:value], class: 'form-control', placeholder: opts[:title] || "Search #{attr.to_s.humanize}" }

          if opts[:skip_button]
            haml_concat label(opts[:namespace], attr, opts[:title] || "Search #{attr.to_s.humanize}")
            haml_concat text_field(opts[:namespace], attr, input_options)
          else
            haml_tag :div, class: 'input-group' do
              haml_concat text_field(opts[:namespace], attr, input_options)
              haml_tag :span, class: 'input-group-btn' do

                haml_tag :button, type: 'button', class: 'btn btn-primary search' do
                  haml_tag :i, class: 'fa fa-search'
                  haml_concat 'Search'
                end
              end
            end
          end
        end
      end
    end

    def self.value(params, name)
      params[name] || params["#{name}_cont"]
    end

  end
end
{'fraction_non_alphanumeric': 0.12542087542087543, 'fraction_numerical': 0.0, 'mean_word_length': 2.10718954248366, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2471997', 'n_tokens_mistral': 718, 'n_tokens_neox': 705, 'n_words': 183}