Sha256: 362b02242fab76d42ff7d52476639fe5c92808bc48edaa07ceb794199f8212fe

Contents?: true

Size: 1.88 KB

Versions: 20

Compression:

Stored size: 1.88 KB

Contents

module Asciidoctor
  module Standoc
    class FormInputMacro < Asciidoctor::Extensions::InlineMacroProcessor
      use_dsl
      named :input

      def process(_parent, target, attr)
        m = %w(id name value disabled readonly checked maxlength minlength)
          .map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
        %{<input type='#{target}' #{m.join}/>}
      end
    end

    class FormLabelMacro < Asciidoctor::Extensions::InlineMacroProcessor
      use_dsl
      named :label
      parse_content_as :text

      def process(parent, target, attr)
        out = Asciidoctor::Inline.new(parent, :quoted, attr["text"]).convert
        %{<label for="#{target}">#{out}</label>}
      end
    end

    class FormTextareaMacro < Asciidoctor::Extensions::InlineMacroProcessor
      use_dsl
      named :textarea
      using_format :short

      def process(_parent, _target, attr)
        m = %w(id name rows cols value)
          .map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
        %{<textarea #{m.join}/>}
      end
    end

    class FormSelectMacro < Asciidoctor::Extensions::InlineMacroProcessor
      use_dsl
      named :select
      using_format :short

      def process(parent, _target, attr)
        m = %w(id name size disabled multiple value)
          .map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
        out = Asciidoctor::Inline.new(parent, :quoted, attr["text"]).convert
        %{<select #{m.join}>#{out}</select>}
      end
    end

    class FormOptionMacro < Asciidoctor::Extensions::InlineMacroProcessor
      use_dsl
      named :option
      using_format :short

      def process(parent, _target, attr)
        m = %w(disabled value)
          .map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
        out = Asciidoctor::Inline.new(parent, :quoted, attr["text"]).convert
        %{<option #{m.join}">#{out}</option>}
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
metanorma-standoc-1.11.4 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.11.3 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.11.2 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.11.1 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.11.0.1 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.11.0 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.8 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.7 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.6 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.5 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.4.1 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.4 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.3.1 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.3 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.2 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.1 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.10.0 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.9.4 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.9.3 lib/asciidoctor/standoc/macros_form.rb
metanorma-standoc-1.9.2 lib/asciidoctor/standoc/macros_form.rb