Module: Nanoc2::Helpers::HTMLEscape

Included in:
LinkTo
Defined in:
lib/nanoc2/helpers/html_escape.rb

Overview

Nanoc2::Helpers::HTMLEscape contains functionality for HTML-escaping strings.

This helper is activated automatically.

Instance Method Summary collapse

Instance Method Details

#html_escape(string) ⇒ Object Also known as: h

Returns the HTML-escaped representation of the given string. Only &, <, > and “ are escaped.



11
12
13
14
15
16
# File 'lib/nanoc2/helpers/html_escape.rb', line 11

def html_escape(string)
  string.gsub('&', '&amp;').
         gsub('<', '&lt;').
         gsub('>', '&gt;').
         gsub('"', '&quot;')
end