Sha256: d3c8bc0048a2d8c676b2b869b09f25cbc64808aa7f6fd855f47dfbe5f8e7dc98

Contents?: true

Size: 494 Bytes

Versions: 5

Compression:

Stored size: 494 Bytes

Contents

module Nanoc::Helpers

  # Nanoc::Helpers::HTMLEscape contains functionality for HTML-escaping
  # strings.
  module HTMLEscape

    # Returns the HTML-escaped representation of the given string. Only &, <,
    # > and " are escaped.
    def html_escape(string)
      string.gsub('&', '&amp;').
             gsub('<', '&lt;').
             gsub('>', '&gt;').
             gsub('"', '&quot;')
    end

    alias h html_escape

  end

end

# Include by default
include Nanoc::Helpers::HTMLEscape

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nanoc-2.1 lib/nanoc/helpers/html_escape.rb
nanoc-2.1.1 lib/nanoc/helpers/html_escape.rb
nanoc-2.1.2 lib/nanoc/helpers/html_escape.rb
nanoc-2.1.3 lib/nanoc/helpers/html_escape.rb
nanoc-2.1.4 lib/nanoc/helpers/html_escape.rb