diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 0e2dce52..2664a01f 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -248,6 +248,15 @@ module Jekyll end end + # Convert an object into its String representation for debugging + # + # input - The Object to be converted + # + # Returns a String representation of the object. + def inspect(input) + CGI.escapeHTML(input.inspect) + end + private def time(input) case input diff --git a/test/test_filters.rb b/test/test_filters.rb index d43dc01b..58841fe8 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -211,5 +211,11 @@ class TestFilters < Test::Unit::TestCase end end + context "inspect filter" do + should "return a HTML-escaped string representation of an object" do + assert_equal "{"<a>"=>1}", @filter.inspect({ "" => 1 }) + end + end + end end