Module: Formtastic::Util

Extended by:
Util
Included in:
Util
Defined in:
lib/formtastic/util.rb

Instance Method Summary collapse

Instance Method Details

#html_safe(text) ⇒ String

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`.

Parameters:

  • text (String)

Returns:

  • (String)

    ‘text`, marked as HTML-safe



13
14
15
16
17
# File 'lib/formtastic/util.rb', line 13

def html_safe(text)
  return text if text.nil?
  return text.html_safe if defined?(ActiveSupport::SafeBuffer)
  return text.html_safe!
end

#rails3?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
33
# File 'lib/formtastic/util.rb', line 27

def rails3?
  version=
    if defined?(ActionPack::VERSION::MAJOR)
      ActionPack::VERSION::MAJOR
    end
  version >= 3
end

#rails_safe_buffer_classObject



19
20
21
22
23
24
25
# File 'lib/formtastic/util.rb', line 19

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