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-2.9.0 lib/roda/plugins/h.rb
roda-2.8.0 lib/roda/plugins/h.rb
roda-2.7.0 lib/roda/plugins/h.rb
roda-2.6.0 lib/roda/plugins/h.rb
roda-2.5.1 lib/roda/plugins/h.rb
roda-2.5.0 lib/roda/plugins/h.rb
roda-2.4.0 lib/roda/plugins/h.rb
roda-2.3.0 lib/roda/plugins/h.rb
roda-2.2.0 lib/roda/plugins/h.rb
roda-2.1.0 lib/roda/plugins/h.rb
roda-2.0.0 lib/roda/plugins/h.rb
roda-1.3.0 lib/roda/plugins/h.rb
roda-1.2.0 lib/roda/plugins/h.rb
roda-1.1.0 lib/roda/plugins/h.rb
roda-cj-1.0.5 lib/roda/plugins/h.rb
roda-cj-1.0.4 lib/roda/plugins/h.rb
roda-cj-1.0.3 lib/roda/plugins/h.rb
roda-cj-1.0.2 lib/roda/plugins/h.rb
roda-cj-1.0.1 lib/roda/plugins/h.rb
roda-cj-1.0.0 lib/roda/plugins/h.rb