Sha256: c444f441c0fa6b7851e43a45f5054204b0f2b8cc65e53fb65d881671cf2a39c2

Contents?: true

Size: 653 Bytes

Versions: 4

Compression:

Stored size: 653 Bytes

Contents

# frozen_string_literal: true

module Redcarpet
  module Form
    module Extension
      module Inline
        # A single input tag
        #
        # Ex: [input]{ type="number" }
        # <input type="number" name="" />
        class Input
          def self.pattern
            /\[input\]([{][^}]*[}])?/
          end

          def self.default_attributes
            { 'type' => 'text', 'name' => Util.random_string }
          end

          def self.html(text)
            attrs = default_attributes.merge!(Util.parse_attributes(text))
            "<input #{Util.attributes_to_s(attrs)} />"
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redcarpet-form-extension-0.4.0 lib/redcarpet/form/extension/inline/input.rb
redcarpet-form-extension-0.3.0 lib/redcarpet/form/extension/inline/input.rb
redcarpet-form-extension-0.2.1 lib/redcarpet/form/extension/inline/input.rb
redcarpet-form-extension-0.2.0 lib/redcarpet/form/extension/inline/input.rb