File: generate_settings.awk

package info (click to toggle)
dwb 20120628hg-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,284 kB
  • sloc: ansic: 13,839; sh: 246; makefile: 127; awk: 78; perl: 8
file content (49 lines) | stat: -rw-r--r-- 1,261 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$1 == "#" {
	$1 = ""; $2 = "";
	sub(/^[[:space:]]*/, "");
  print "<tr class='dwb_table_row'>"
	print "  <th class='dwb_table_headline' colspan='3'>" $0 "</th>"
	print "</tr>"
	next
}

$2 == "select" {
	id = $1; $1 = ""; $2 = ""; options = ""
	for (i = 3; $i ~ /^@/ && i <= NF; ++i) {
    value = substr($i, 2)
		gsub(/_/, " ", value)
		options = options "<option>" value "</option>"
		$i = ""
	}
	sub(/^[[:space:]]*/, "")
  if (NR % 2 == 0) {
    print "<tr class='dwb_table_row_even'>"
  }
  else {
    print "<tr class='dwb_table_row_odd'>"
  }
	print "  <td class='dwb_table_cell_left'>" id "</td>"
	print "  <td class='dwb_table_cell_middle'>" $0 "</td>"
	print "  <td class='dwb_table_cell_right'>"
        print "    <select id='" id "'>"
	print "      " options
        print "    </select>"
	print "  </td>"
	print "</tr>"
	next
}

NF > 0 {
	id = $1; type = $2; $1 = ""; $2 = ""
	sub(/^[[:space:]]*/, "")
  if (NR % 2 == 0) {
    print "<tr class='dwb_table_row_even'>"
  }
  else {
    print "<tr class='dwb_table_row_odd'>"
  }
	print "  <td class='dwb_table_cell_left'>" id "</td>"
	print "  <td class='dwb_table_cell_middle'>" $0 "</td>"
	print "  <td class='dwb_table_cell_right'><input id='" id "' type='" type "'></input></td>"
	print "</tr>"
}