Sha256: 4fba2708060bc4ff73ee1203b924a265558c7fbcb484563b97965d4e35bba9ae

Contents?: true

Size: 1.53 KB

Versions: 19

Compression:

Stored size: 1.53 KB

Contents

require 'active_support/core_ext/string/output_safety'
module Hobo
  module Helper
    module Translations
      module Normalizer

        private

        def normalize_args(key, options={})
          if (key.class == Hash) # called as a tag
            if key.has_key?(:default) && !key[:default].blank?
              Rails.logger.warn "hobo-i18n: 'default' should not be used as an attribute on *translate tags. If used, then you need to make sure that the tags inner-contents are not used. These are normally treated as defaults automatically, but if there is a default attribute then that inner-content will be hidden from this method - and will not be replaced with the translation found."
            end
            defaults = options[:default]
            options = key
            key = options.delete(:key)
            # Set options[:default] to complete the tag-argument-conversion process.
            options[:default] = defaults.call(options) if defaults.class == Proc
          end
          escape_options(options)
          options[:default] = Array.wrap options[:default]
          [key, options]
        end

        def escape_options(options)
          options.each_pair do |k,v|
            options[k] = case v
                         when Array
                            v.map {|i| i.respond_to?(:html_safe) ? ERB::Util.html_escape(i) : i}
                         else
                           v.respond_to?(:html_safe) ? ERB::Util.html_escape(v) : v
                         end
          end
        end

      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
hobo-1.3.3 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.2 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.1 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.RC4 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.RC3 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.RC2 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.RC1 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.RC lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre31 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre29 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre28 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre27 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre26 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre25 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre24 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre23 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre22 lib/hobo/helper/translations/normalizer.rb
hobo-1.3.0.pre21 lib/hobo/helper/translations/normalizer.rb