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`.
15 16 17 18 19 20 |
# File 'lib/formtastic/util.rb', line 15 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? ⇒ Boolean
30 31 32 33 34 35 36 |
# File 'lib/formtastic/util.rb', line 30 def rails3? version= if defined?(ActionPack::VERSION::MAJOR) ActionPack::VERSION::MAJOR end !version.blank? && version >= 3 end |
#rails_safe_buffer_class ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/formtastic/util.rb', line 22 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 |