Sha256: c063e29bf8f1aee3316efaf64a2027356eed5a2fe665e1df7500cfa05ea95d9a

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8

# Adapted from the rails3 compatibility shim in Haml 2.2
module Formtastic
  # @private
  module Util
    extend self
    ## Rails XSS Safety

    # Returns the given text, marked as being HTML-safe.
    # With older versions of the Rails XSS-safety mechanism,
    # this destructively modifies the HTML-safety of `text`.
    #
    # @param text [String]
    # @return [String] `text`, marked as HTML-safe
    def html_safe(text)
      if text.respond_to?(:html_safe)
        text.html_safe
      else
        text
      end
    end
    
    def rails3?
      rails_version >= Gem::Version.new("3.0.0") && 
      rails_version < Gem::Version.new("4.0.0")
    end

    def rails4?
      rails_version >= Gem::Version.new("4.0.0") && 
      rails_version < Gem::Version.new("5.0.0")
    end
    
    def rails4_0?
      rails_version >= Gem::Version.new("4.0.0") && 
      rails_version < Gem::Version.new("4.1.0")
    end

    def rails4_1?
      rails_version >= Gem::Version.new("4.1.0") && 
      rails_version < Gem::Version.new("4.2.0")
    end
    
    def deprecated_version_of_rails?
      rails_version < Gem::Version.new("4.0.4")
    end

    def rails_version
      Gem::Version.new(::Rails::VERSION::STRING)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
formtastic-3.0.0 lib/formtastic/util.rb
formtastic-3.0.0.rc2 lib/formtastic/util.rb
formtastic-3.0.0.rc lib/formtastic/util.rb