aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-10-19 23:07:29 +0200
committerXavier Noria <fxn@hashref.com>2010-10-19 23:07:29 +0200
commitd619b9d1d1ad8d7497bf24283b2318c056283f48 (patch)
treed0a937b8630d4244eb91f45398dfe2be69ba6c45 /activesupport
parent95d87823d4c9837e7a491fb4469869c5b2de5e05 (diff)
parente43de58ab449218ab2d56e30e54e429aadcb8a1b (diff)
downloadrails-d619b9d1d1ad8d7497bf24283b2318c056283f48.tar.gz
rails-d619b9d1d1ad8d7497bf24283b2318c056283f48.tar.bz2
rails-d619b9d1d1ad8d7497bf24283b2318c056283f48.zip
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index af7539881a..37c206ea3c 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -36,10 +36,16 @@ class ERB
# A utility method for escaping HTML entities in JSON strings.
# This method is also aliased as <tt>j</tt>.
#
+ # Note that after this operation is performed the output is not
+ # a valid JSON.
+ #
# In your ERb templates, use this method to escape any HTML entities:
# <%=j @person.to_json %>
#
# ==== Example:
+ # puts json_escape("{\"name\":\"john\",\"created_at\":\"2010-04-28T01:39:31Z\",\"id\":1}")
+ # # => {name:john,created_at:2010-04-28T01:39:31Z,id:1}
+ #
# puts json_escape("is a > 0 & a < 10?")
# # => is a \u003E 0 \u0026 a \u003C 10?
def json_escape(s)