Sha256: dea06b49d6ad27d0cce4d8560e91c6cdf519bf2176cf8d39af8c2b04377aafc5

Contents?: true

Size: 1.84 KB

Versions: 119

Compression:

Stored size: 1.84 KB

Contents

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

      def input_parse(node, out)
        out.input nil, **attr_code(
          id: node["id"], name: node["name"], type: node["type"],
          value: node["value"], disabled: node["disabled"],
          readonly: node["readonly"], checked: node["checked"],
          maxlength: node["maxlength"], minlength: node["minlength"]
        )
      end

      def select_parse(node, out)
        selected = node.at(ns("./option[@value = '#{node['value']}']"))
        selected and selected["selected"] = true
        out.select **attr_code(
          id: node["id"], name: node["name"], size: node["size"],
          disabled: node["disabled"], multiple: node["multiple"]
        ) do |div|
          node.children.each do |n|
            parse(n, div)
          end
        end
      end

      def label_parse(node, out)
        out.label **attr_code(for: node["for"]) do |div|
          node.children.each do |n|
            parse(n, div)
          end
        end
      end

      def option_parse(node, out)
        out.option **attr_code(
          disabled: node["disabled"], selected: node["selected"],
          value: node["value"]
        ) do |o|
          node.children.each do |n|
            parse(n, o)
          end
        end
      end

      def textarea_parse(node, out)
        out.textarea **attr_code(
          id: node["id"], name: node["name"], rows: node["rows"],
          cols: node["cols"]
        ) do |div|
          node["value"] and div << node["value"]
        end
      end
    end
  end
end

Version data entries

119 entries across 119 versions & 1 rubygems

Version Path
isodoc-2.6.4 lib/isodoc/html_function/form.rb
isodoc-2.6.3 lib/isodoc/html_function/form.rb
isodoc-2.6.2 lib/isodoc/html_function/form.rb
isodoc-2.6.1 lib/isodoc/html_function/form.rb
isodoc-2.6.0 lib/isodoc/html_function/form.rb
isodoc-2.5.10 lib/isodoc/html_function/form.rb
isodoc-2.5.9 lib/isodoc/html_function/form.rb
isodoc-2.5.8 lib/isodoc/html_function/form.rb
isodoc-2.5.7 lib/isodoc/html_function/form.rb
isodoc-2.5.6 lib/isodoc/html_function/form.rb
isodoc-2.5.5 lib/isodoc/html_function/form.rb
isodoc-2.5.4 lib/isodoc/html_function/form.rb
isodoc-2.5.3 lib/isodoc/html_function/form.rb
isodoc-2.5.2 lib/isodoc/html_function/form.rb
isodoc-2.5.1 lib/isodoc/html_function/form.rb
isodoc-2.5.0 lib/isodoc/html_function/form.rb
isodoc-2.4.5 lib/isodoc/html_function/form.rb
isodoc-2.4.4 lib/isodoc/html_function/form.rb
isodoc-2.4.3 lib/isodoc/html_function/form.rb
isodoc-2.4.2 lib/isodoc/html_function/form.rb