Sha256: 495ca0f6fb245ad17bea0c066693f683d1ac44b72055011a0635176f3323c494

Contents?: true

Size: 456 Bytes

Versions: 2

Compression:

Stored size: 456 Bytes

Contents

module Brightcontent
  module BaseHelper
    def render_list_field(item, field)
      render_if_exists("list_field_#{field}", item: item) || item.send(field).to_s.truncate(50)
    end

    def render_form_field(form, field)
      render_if_exists("form_field_#{field}", form: form, item: form.object) || form.input(field.to_sym)
    end

    def render_if_exists(*args)
      render *args
    rescue ActionView::MissingTemplate
      nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brightcontent-core-2.0.1 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.0.0.alpha6 app/helpers/brightcontent/base_helper.rb