Module Nanoc::Helpers::HTMLEscape
In: lib/nanoc/helpers/html_escape.rb

Contains functionality for HTML-escaping strings.

Methods

h   html_escape  

Included Modules

Nanoc::Helpers::Capturing

Public Instance methods

h(string=nil, &block)

Alias for html_escape

Returns the HTML-escaped representation of the given string or the given block. Only `&`, `<`, `>` and `"` are escaped. When given a block, the contents of the block will be escaped and appended to the output buffer, `_erbout`.

@example Escaping a string

    h('<br>')
    # => '&lt;br&gt;'

@example Escaping with a block

    <% h do %>
      <h1>Hello <em>world</em>!</h1>
    <% end %>
    # The buffer will now contain “&lt;h1&gt;Hello &lt;em&gt;world&lt;/em&gt;!&lt;/h1&gt;”

@param [String] string The string to escape

@return [String] The escaped string

[Validate]