Sha256: 6ce1b96587afc147ce5d083bee1b4248da05701cb9e7b26f5cb5560db19a8665

Contents?: true

Size: 557 Bytes

Versions: 8

Compression:

Stored size: 557 Bytes

Contents

# frozen-string-literal: true

#
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

8 entries across 8 versions & 1 rubygems

Version Path
roda-2.18.0 lib/roda/plugins/h.rb
roda-2.17.0 lib/roda/plugins/h.rb
roda-2.16.0 lib/roda/plugins/h.rb
roda-2.15.0 lib/roda/plugins/h.rb
roda-2.14.0 lib/roda/plugins/h.rb
roda-2.13.0 lib/roda/plugins/h.rb
roda-2.12.0 lib/roda/plugins/h.rb
roda-2.11.0 lib/roda/plugins/h.rb