<commit_before># encoding: utf-8
module DynamicFieldsForHelper

  def link_to_add_fields(form, association, name=nil, css_classes=nil, &block)
    new_object = form.object.send(association).klass.new
    id = new_object.object_id
    fields = form.fields_for(association, new_object, child_index: id) do |builder|
      render("#{form.object.class.name.downcase.pluralize}/#{association.to_s.singularize}_fields", fields: builder)
    end
    css_classes = css_classes(DynamicFieldsForRails.add_css_classes, css_classes)
    if block_given?
    	link_to('#', class: css_classes, data: {id: id, fields: fields.gsub("\n", "")}, &block)
    else
    	link_to(name, '#', class: css_classes, data: {id: id, fields: fields.gsub("\n", "")})
  	end
  end

  def link_to_delete_fields(fields, name=nil, css_classes=nil, &block)
    link = []
    link << fields.hidden_field(:_destroy)
    css_classes = css_classes(DynamicFieldsForRails.delete_css_classes, css_classes)
    if block_given?
      link << link_to('#', class: css_classes, title: name, &block)
    else
      link << link_to(name, '#', class: css_classes)
    end
    return link.join('').html_safe<commit_msg>Use options hash instead of helper attributes, allow override of partial name<commit_after># encoding: utf-8
module DynamicFieldsForHelper

  def link_to_add_fields(form, association, options, &block)
    partial = options[:partial] || nil
    name = options[:name] || nil
    css_classes = options[:class] || nil

    new_object = form.object.send(association).klass.new
    id = new_object.object_id
    fields = form.fields_for(association, new_object, child_index: id) do |builder|
      if partial
        render("#{form.object.class.name.downcase.pluralize}/#{partial}", fields: builder)
      else
        render("#{form.object.class.name.downcase.pluralize}/#{association.to_s.singularize}_fields", fields: builder)
      end
    end
    css_classes = css_classes(DynamicFieldsForRails.add_css_classes, css_classes)
    if block_given?
    	link_to('#', class: css_classes, data: {id: id, fields: fields.gsub("\n", "")}, &block)
    else
    	link_to(name, '#', class: css_classes, data: {id: id, fields: fields.gsub("\n", "")})
  	end
  end

  def link_to_delete_fields(fields, name=nil, css_classes=nil, &block)
    link = []
    link << fields.hidden_field(:_destroy)
    css_classes = css_classes(DynamicFieldsForRails.delete_css_classes, css_classes)
    if block_given?
      link << link_to('#', class: css_classes, title: name, &block)
    else
      link << link_to(name, '#', class: css_classes)
    end
    return link.join('').html_safe
{'fraction_non_alphanumeric': 0.1350629530713468, 'fraction_numerical': 0.0007630675314765357, 'mean_word_length': 4.223107569721115, 'pattern_counts': {'":': 0, '<': 15, '<?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': '6706234', 'n_tokens_mistral': 869, 'n_tokens_neox': 860, 'n_words': 183}