Module: Formtastic::Util
Instance Method Summary collapse
-
#html_safe(text) ⇒ String
Returns the given text, marked as being HTML-safe.
- #rails3? ⇒ Boolean
- #rails_safe_buffer_class ⇒ Object
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`.
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
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_class ⇒ Object
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 |