Sha256: 0d723dff9219ecc349e76ed643b779ddb12094c69444474045234f88af381ca1

Contents?: true

Size: 407 Bytes

Versions: 6

Compression:

Stored size: 407 Bytes

Contents

# backtick_javascript: true

require 'template'

class ERB
  module Util
    `var escapes = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;'};`
    `var escape_regexp = /[&<>"']/g;`

    def html_escape(str)
      `("" + str).replace(escape_regexp, function (m) { return escapes[m] })`
    end

    alias h html_escape

    module_function :h
    module_function :html_escape
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 stdlib/erb.rb
opal-1.8.2 stdlib/erb.rb
opal-1.8.1 stdlib/erb.rb
opal-1.8.0 stdlib/erb.rb
opal-1.8.0.beta1 stdlib/erb.rb
opal-1.8.0.alpha1 stdlib/erb.rb