Sha256: df1f1c8948db067326370473aa4d69f7bd3b4b5d7e34f6338a6b5abc7210eab0

Contents?: true

Size: 1.28 KB

Versions: 129

Compression:

Stored size: 1.28 KB

Contents

module IsoDoc
  module Function
    module Form
      def form_parse(node, out)
        out.div **attr_code(class: node["class"],
                            id: node["id"]) do |div|
          node.children.each do |n|
            parse(n, div)
          end
        end
      end

      def input_parse(node, out)
        case node["type"]
        when "button" then out << "[#{node['value'] || 'BUTTON'}]"
        when "checkbox" then out << "&#x2610; "
        when "date", "file", "password" then text_input(out)
        when "radio" then out << "&#x25CE; "
        when "submit" # nop
        when "text" then text_input(out, node["maxlength"])
        end
      end

      def text_input(out, length = 10)
        length ||= 10
        length = length.to_i
        length.zero? and length = 10
        out << "_" * length
        out << " "
      end

      def select_parse(node, out)
        text_input(out, node["size"] || 10)
      end

      def label_parse(node, out)
        node.children.each do |n|
          parse(n, out)
        end
      end

      def option_parse(node, out); end

      def textarea_parse(_node, out)
        out.table **{ border: 1, width: "50%" } do |t|
          t.tr do |tr|
            tr.td do |td|
            end
          end
        end
      end
    end
  end
end

Version data entries

129 entries across 129 versions & 1 rubygems

Version Path
isodoc-3.1.3 lib/isodoc/function/form.rb
isodoc-3.1.2 lib/isodoc/function/form.rb
isodoc-3.1.1 lib/isodoc/function/form.rb
isodoc-3.1.0 lib/isodoc/function/form.rb
isodoc-3.0.4 lib/isodoc/function/form.rb
isodoc-3.0.3 lib/isodoc/function/form.rb
isodoc-3.0.2 lib/isodoc/function/form.rb
isodoc-3.0.1 lib/isodoc/function/form.rb
isodoc-3.0.0 lib/isodoc/function/form.rb
isodoc-2.12.9 lib/isodoc/function/form.rb
isodoc-2.12.8 lib/isodoc/function/form.rb
isodoc-2.12.7 lib/isodoc/function/form.rb
isodoc-2.12.6 lib/isodoc/function/form.rb
isodoc-2.12.5 lib/isodoc/function/form.rb
isodoc-2.12.4 lib/isodoc/function/form.rb
isodoc-2.12.3 lib/isodoc/function/form.rb
isodoc-2.12.2 lib/isodoc/function/form.rb
isodoc-2.12.1 lib/isodoc/function/form.rb
isodoc-2.12.0 lib/isodoc/function/form.rb
isodoc-2.11.4 lib/isodoc/function/form.rb