Add inspect filter

This commit is contained in:
Shu Uesugi 2014-09-01 14:47:55 -07:00
parent e4975836f4
commit cfd17b2e7d
2 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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 "{&quot;&lt;a&gt;&quot;=&gt;1}", @filter.inspect({ "<a>" => 1 })
end
end
end
end