Sha256: 5365411b7884209f43151c3dc85646292dd142c22aeccec8a40025f45ce75af8
Contents?: true
Size: 929 Bytes
Versions: 3
Compression:
Stored size: 929 Bytes
Contents
require 'action_view/helpers' if defined?(Rails) require 'action_view/context' if defined?(Rails) module InlineSvg module ActionView module Helpers 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 private def configured_asset_file InlineSvg.configuration.asset_file end def extension_hint(filename) filename.ends_with?(".svg") ? "" : "(Try adding .svg to your filename) " end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
inline_svg-1.2.1 | lib/inline_svg/action_view/helpers.rb |
inline_svg-1.2.0 | lib/inline_svg/action_view/helpers.rb |
inline_svg-1.1.0 | lib/inline_svg/action_view/helpers.rb |