Sha256: 94f923f335756af0ed94996e742b5aa27a65288b24bbf7261be73d18468b8ba7

Contents?: true

Size: 537 Bytes

Versions: 71

Compression:

Stored size: 537 Bytes

Contents

needed = "".respond_to?(:html_safe) and
  (
    "".html_safe % {:x => '<br/>'} == '<br/>' or
    not ("".html_safe % {:x=>'a'}).html_safe?
  )

if needed
  class String
    alias :interpolate_without_html_safe :%

    def %(*args)
      if args.first.is_a?(Hash) and html_safe?
        safe_replacement = Hash[args.first.map{|k,v| [k,ERB::Util.h(v)] }]
        interpolate_without_html_safe(safe_replacement).html_safe
      else
        interpolate_without_html_safe(*args).dup # make sure its not html_safe
      end
    end
  end
end

Version data entries

71 entries across 71 versions & 2 rubygems

Version Path
gettext_i18n_rails-1.13.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.12.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.11.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.10.1 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.10.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.9.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.8.1 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.8.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.7.2 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.7.1 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.7.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.6.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.5.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.4.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.3.2 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.3.1 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.3.0 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.2.3 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.2.2 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-1.2.1 lib/gettext_i18n_rails/string_interpolate_fix.rb