Sha256: 3a0dfc85ff69733fce9ec3607a1c2c51ef9a2129e65cb8ea55a6c8a300943438

Contents?: true

Size: 536 Bytes

Versions: 21

Compression:

Stored size: 536 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

21 entries across 21 versions & 2 rubygems

Version Path
zena-1.2.8 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.2.7 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.2.6 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.2.5 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.2.4 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.2.3 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.2.2 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.2.1 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.2.0 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.1.3 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.1.2 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.1.1 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.1.0 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.0.0 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-0.2.20 lib/gettext_i18n_rails/string_interpolate_fix.rb
zena-1.0.0.rc3 vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-0.2.19 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-0.2.18 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-0.2.17 lib/gettext_i18n_rails/string_interpolate_fix.rb
gettext_i18n_rails-0.2.16 lib/gettext_i18n_rails/string_interpolate_fix.rb