Skip to content

Commit

Permalink
Remove legacy conditional check
Browse files Browse the repository at this point in the history
`ERB::Util.html_escape_once` is available in all supported Rails
versions

Close jamesmartin#164
  • Loading branch information
tagliala committed Sep 3, 2024
1 parent 9680fb8 commit b1bf1b9
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions lib/inline_svg/action_view/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ def inline_svg(filename, transform_params={})

private

def backwards_compatible_html_escape(filename)
# html_escape_once was introduced in newer versions of Rails.
if ERB::Util.respond_to?(:html_escape_once)
ERB::Util.html_escape_once(filename)
else
ERB::Util.html_escape(filename)
end
end

def render_inline_svg(filename, transform_params={})
begin
svg_file = read_svg(filename)
Expand Down Expand Up @@ -60,7 +51,7 @@ def read_svg(filename)

def placeholder(filename)
css_class = InlineSvg.configuration.svg_not_found_css_class
not_found_message = "'#{backwards_compatible_html_escape(filename)}' #{extension_hint(filename)}"
not_found_message = "'#{ERB::Util.html_escape_once(filename)}' #{extension_hint(filename)}"

if css_class.nil?
return "<svg><!-- SVG file not found: #{not_found_message}--></svg>".html_safe
Expand Down

0 comments on commit b1bf1b9

Please sign in to comment.