lib/angular_xss/haml.rb in angular_xss-0.3.1 vs lib/angular_xss/haml.rb in angular_xss-0.4.0
- old
+ new
@@ -1,6 +1,6 @@
-# Haml > 5 falls back to erb
+# Haml 5.0 and 5.1 fall back to erb
if Haml::VERSION < '5'
# Use module_eval so we crash when Haml::Helpers has not yet been loaded.
Haml::Helpers.module_eval do
def html_escape_with_escaping_angular_expressions(s)
@@ -12,8 +12,21 @@
end
end
alias_method :html_escape_without_escaping_angular_expressions, :html_escape
alias_method :html_escape, :html_escape_with_escaping_angular_expressions
+ end
+elsif Haml::VERSION >= '5.2'
+ Haml::Helpers.module_eval do
+
+ def html_escape_without_haml_xss_with_escaping_angular_expressions(s)
+ s = s.to_s
+ return s if s.html_safe?
+
+ html_escape_without_haml_xss_without_escaping_angular_expressions(AngularXss::Escaper.escape(s))
+ end
+
+ alias_method :html_escape_without_haml_xss_without_escaping_angular_expressions, :html_escape_without_haml_xss
+ alias_method :html_escape_without_haml_xss, :html_escape_without_haml_xss_with_escaping_angular_expressions
end
end