app/helpers/rjs_helper.rb in rjs_helpers-0.0.3 vs app/helpers/rjs_helper.rb in rjs_helpers-0.0.4

- old
+ new

@@ -132,18 +132,27 @@ %{rjsHelpers.#{js_function}(#{string_args(js_args)});} end end def string_args(args) - args.map {|a| a.is_a?(Numeric) ? a : "'#{a}'"}.join(', ') + args.map {|a| a.is_a?(Numeric) ? a : ('"' + fixed_escape_javascript(a.to_s) + '"')}.join(', ') end # Processes the given content. # Strings are simply forwarded while Hashes # are passed to Rails' +render+ function. # Also, it automatically escapes javascript in the given content #-------------------------------------------------------------- def rendered_content(content) - escape_javascript(content.is_a?(Hash) ? render(content) : content) + content.is_a?(Hash) ? render(content) : content + end + + # + # The Rails +escape_javascript+ helper does not seem to automatically + # escape unicode newline elements which causes javascript strings + # to break. This method escapes these sequences. + # + def fixed_escape_javascript(text) + escape_javascript(text).gsub("\342\200\250", "
") end end