[Haml] Allow Haml::Util.html_safe to take nil.

This commit is contained in:
Nathan Weizenbaum 2010-03-21 16:03:27 -07:00
parent 3e21850960
commit be8080b271
2 changed files with 5 additions and 2 deletions

View File

@ -16,6 +16,8 @@
* Make loading the gemspec not crash on read-only filesystems like Heroku's.
* Don't crash when methods like `form_for` return `nil` in, for example, Rails 3 beta.
## 2.2.21
[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.21).

View File

@ -210,9 +210,10 @@ module Haml
# 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
# @param text [String, nil]
# @return [String, nil] `text`, marked as HTML-safe
def html_safe(text)
return unless text
return text.html_safe if defined?(ActiveSupport::SafeBuffer)
text.html_safe!
end