lib/nanoc/helpers/html_escape.rb in nanoc-4.1.6 vs lib/nanoc/helpers/html_escape.rb in nanoc-4.2.0b1
- old
+ new
@@ -32,9 +32,14 @@
# Append filtered data to buffer
buffer = eval('_erbout', block.binding)
buffer << escaped_data
elsif string
+ unless string.is_a? String
+ raise ArgumentError, 'The #html_escape or #h function needs either a ' \
+ "string or a block to HTML-escape, but #{string.class} was given"
+ end
+
string
.gsub('&', '&')
.gsub('<', '<')
.gsub('>', '>')
.gsub('"', '"')