Module: IsoDoc::Function::Form

Included in:
Common
Defined in:
lib/isodoc/function/form.rb

Instance Method Summary collapse

Instance Method Details

#form_parse(node, out) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/isodoc/function/form.rb', line 4

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

#input_parse(node, out) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/isodoc/function/form.rb', line 13

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

#label_parse(node, out) ⇒ Object



36
37
38
39
40
# File 'lib/isodoc/function/form.rb', line 36

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

#option_parse(node, out) ⇒ Object



42
# File 'lib/isodoc/function/form.rb', line 42

def option_parse(node, out); end

#select_parse(node, out) ⇒ Object



32
33
34
# File 'lib/isodoc/function/form.rb', line 32

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

#text_input(out, length = 10) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/isodoc/function/form.rb', line 24

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

#textarea_parse(_node, out) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/isodoc/function/form.rb', line 44

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