Sha256: 6ce0e4eaeb3c6c39d14d0057c1f385aaf179c3c56493736cfd44c15051118ec9

Contents?: true

Size: 849 Bytes

Versions: 62

Compression:

Stored size: 849 Bytes

Contents

module Workarea
  module Admin
    module ContentBlockIconHelper
      # This is a direct copy from the `inline_svg` helper, in order to give us
      # better control over the `rescue` state.
      # https://github.com/jamesmartin/inline_svg/blob/v1.2.1/lib/inline_svg/action_view/helpers.rb
      def content_block_icon(filename, transform_params={})
        begin
          svg_file = if InlineSvg::IOResource === filename
            InlineSvg::IOResource.read filename
                     else
            configured_asset_file.named filename
          end
        rescue InlineSvg::AssetFile::FileNotFound
          return inline_svg('workarea/admin/content_block_types/custom_block.svg', transform_params)
        end

        InlineSvg::TransformPipeline.generate_html_from(svg_file, transform_params).html_safe
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.4.13 app/helpers/workarea/admin/content_block_icon_helper.rb
workarea-admin-3.4.12 app/helpers/workarea/admin/content_block_icon_helper.rb