-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsteps.pl
33 lines (32 loc) · 784 Bytes
/
steps.pl
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
#!/usr/bin/perl -w
# Render the steps as HTML templates
use v5.30;
use Data::Dumper;
use standard;
sub renderPage {
my ($n, $type_name, $value) = @_;
say qq(<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Grammatisch</title>
</head>
<body>
<form action="/step@{[sprintf "%02d", $n + 1]}" method="post">
<div>
<label for="$type_name">$type_name</label>);
if (ref($value) eq 'ARRAY') { # is option
say qq[<select id="$type_name" name="$type_name">];
for ($value->@*) {
say qq[<option value="$_">$_</option>];
}
say '</select>';
} else {
say qq[<textarea id="$type_name" name="$type_name"> {{ .$type_name }} </textarea>];
}
say '</div>
<input type="submit"/>
</form>
</body>
</html>';
}