Sha256: 37dd69afe654d7d6e1dd9afd1a2772d183fac330d84c9b6f07cd9131ef8c4166

Contents?: true

Size: 973 Bytes

Versions: 7

Compression:

Stored size: 973 Bytes

Contents

module Administrate
  module ApplicationHelper
    def render_field(field, locals = {})
      locals.merge!(field: field)
      render locals: locals, partial: field.to_partial_path
    end

    def display_resource_name(resource_name)
      resource_name.
        to_s.
        classify.
        constantize.
        model_name.
        human(
          count: 0,
          default: resource_name.to_s.pluralize.titleize,
        )
    end

    def svg_tag(asset, svg_id, options = {})
      svg_attributes = {
        "xlink:href".freeze => "#{asset_url(asset)}##{svg_id}",
        height: options[:height],
        width: options[:width],
      }.delete_if { |_key, value| value.nil? }
      xml_attributes = {
        "xmlns".freeze => "http://www.w3.org/2000/svg".freeze,
        "xmlns:xlink".freeze => "http://www.w3.org/1999/xlink".freeze,
      }

      content_tag :svg, xml_attributes do
        content_tag :use, nil, svg_attributes
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
administrate-0.2.2 app/helpers/administrate/application_helper.rb
administrate-0.2.1 app/helpers/administrate/application_helper.rb
administrate-0.2.0 app/helpers/administrate/application_helper.rb
administrate-0.2.0.rc1 app/helpers/administrate/application_helper.rb
administrate-0.1.5 app/helpers/administrate/application_helper.rb
administrate-0.1.4 app/helpers/administrate/application_helper.rb
administrate-0.1.3 app/helpers/administrate/application_helper.rb