Module: InlineSvg::ActionView::Helpers

Defined in:
lib/inline_svg/action_view/helpers.rb

Instance Method Summary collapse

Instance Method Details

#inline_svg(filename, transform_params = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/inline_svg/action_view/helpers.rb', line 7

def inline_svg(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 "<svg><!-- SVG file not found: '#{filename}' #{extension_hint(filename)}--></svg>".html_safe
  end

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