Sha256: 6707567a02937cfcc5091b2d7827a89febc38542930f075484235c2d2e0ba030

Contents?: true

Size: 865 Bytes

Versions: 4

Compression:

Stored size: 865 Bytes

Contents

module Bhf
  module EntriesHelper
    
    def node(f, field, &block)
      render partial: 'bhf/helper/node', locals: {f: f, field: field, input: with_output_buffer(&block)}
    end

    def reflection_node(f, field, &block)
      return if field.form_type == :static && f.object.new_record? && f.object.send(field.reflection.name).blank?
      render partial: 'bhf/helper/reflection_node', locals: {
        f: f, field: field, input: with_output_buffer(&block)
      }
    end

    def is_image?(file)
      file.match(/\.png|\.jpg|\.jpeg|\.gif|\.svg/i).to_b
    end

    def reflection_title(f, field)
      title = f.object.class.human_attribute_name(field.reflection.name)
      if field.link
        title = t("bhf.platforms.#{field.link}.title", count: f.object.send(field.reflection.name).to_a.count, default: title)
      end
      title
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bhf-0.4.2.7 app/helpers/bhf/entries_helper.rb
bhf-0.4.2.5 app/helpers/bhf/entries_helper.rb
bhf-0.4.2.4 app/helpers/bhf/entries_helper.rb
bhf-0.4.2.3 app/helpers/bhf/entries_helper.rb