Sha256: a68f8ebe61c76e67dda63fa163db1458b371bbe1ef3952179ac2054cb3e8d591

Contents?: true

Size: 542 Bytes

Versions: 5

Compression:

Stored size: 542 Bytes

Contents

module Nanoc::Helpers

  # Nanoc::Helpers::HTMLEscape contains functionality for HTML-escaping
  # strings.
  #
  # This helper is activated automatically.
  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.5 lib/nanoc/helpers/html_escape.rb
nanoc-2.1.6 lib/nanoc/helpers/html_escape.rb
nanoc-2.2 lib/nanoc/helpers/html_escape.rb
nanoc-2.2.1 lib/nanoc/helpers/html_escape.rb
nanoc-2.2.2 lib/nanoc/helpers/html_escape.rb