Sha256: 9076308046042f825aca4add3187e666f97a7b5cd5ff01d541cef3a24f5484c5

Contents?: true

Size: 524 Bytes

Versions: 28

Compression:

Stored size: 524 Bytes

Contents

class Roda
  module RodaPlugins
    # The h plugin adds an +h+ instance method that will HTML
    # escape the input and return it.
    #
    # The following example will return "<foo>" as the body.
    #
    #   plugin :h
    #
    #   route do |r|
    #     h('<foo>')
    #   end
    module H
      module InstanceMethods
        # HTML escape the input and return the escaped version.
        def h(s)
          ::Rack::Utils.escape_html(s.to_s)
        end
      end
    end

    register_plugin(:h, H)
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
roda-1.0.0 lib/roda/plugins/h.rb
roda-cj-0.9.6 lib/roda/plugins/h.rb
roda-cj-0.9.5 lib/roda/plugins/h.rb
roda-cj-0.9.4 lib/roda/plugins/h.rb
roda-cj-0.9.3 lib/roda/plugins/h.rb
roda-cj-0.9.2 lib/roda/plugins/h.rb
roda-cj-0.9.1 lib/roda/plugins/h.rb
roda-0.9.0 lib/roda/plugins/h.rb