Module: Nanoc3::Helpers::HTMLEscape

Included in:
LinkTo, Tagging
Defined in:
lib/nanoc3/helpers/html_escape.rb

Overview

Contains functionality for HTML-escaping strings.

Instance Method Summary (collapse)

Instance Method Details

- (String) html_escape(string) Also known as: h

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

Parameters:

  • string (String)

    The string to escape

Returns:

  • (String)

    The escaped string



14
15
16
17
18
19
# File 'lib/nanoc3/helpers/html_escape.rb', line 14

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