module Formtastic::Util

Public Instance Methods

html_safe(text) click to toggle source

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

# File lib/formtastic/util.rb, line 14
def html_safe(text)
  return text if text.nil?
  return text.html_safe if defined?(ActiveSupport::SafeBuffer)
  return text.html_safe! if text.respond_to?(:html_safe!)
  text
end
rails3?() click to toggle source
# File lib/formtastic/util.rb, line 29
def rails3?
  version=
    if defined?(ActionPack::VERSION::MAJOR)
      ActionPack::VERSION::MAJOR
    end
  !version.blank? && version >= 3
end
rails_safe_buffer_class() click to toggle source
# File lib/formtastic/util.rb, line 21
def rails_safe_buffer_class
  # It's important that we check ActiveSupport first,
  # because in Rails 2.3.6 ActionView::SafeBuffer exists
  # but is a deprecated proxy object.
  return ActiveSupport::SafeBuffer if defined?(ActiveSupport::SafeBuffer)
  return ActionView::SafeBuffer
end