-
Notifications
You must be signed in to change notification settings - Fork 0
/
html_document.go
58 lines (52 loc) · 1.73 KB
/
html_document.go
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
50
51
52
53
54
55
56
57
58
package main
import "github.com/osteele/liquid"
type cardParameters struct {
Title1, Body1, Title2, Body2 string
}
func getHtmlDocument(pageTitle string, params []cardParameters) (string, error) {
engine := liquid.NewEngine()
bindings := map[string]interface{}{
"pageTitle": pageTitle,
"cards": params,
}
return engine.ParseAndRenderString(resultDocument, bindings)
}
func getInstructionsDocument() string {
return instructionsDocument
}
const resultDocument = `<!doctype html>
<html>
<title>{{ pageTitle }}</title>
<link rel="stylesheet" type="text/css" href="/static/main.css">
</head>
<body>
{% for card in cards %}<div class="card">
<p class="title">{{ card.Title1 }}</p>
<p>{{ card.Body1 }}</p>
<p class="title">{{ card.Title2 }}</p>
<p>{{ card.Body2 }}</p>
</div>{% endfor %}
</body>
</html>
`
const instructionsDocument = `<!doctype html>
<html>
<title>Data axe</title>
<link rel="stylesheet" type="text/css" href="/static/main.css">
</head>
<body>
<div class="card">
<p class="title">Try one of these</p>
<p class="example"><a href="/api?code=21">/api?code=21</a></p>
<p class="example"><a href="/mcc?code=410">/mcc?code=410</a></p>
<p class="example"><a href="/http?code=451">/http?code=451</a></p>
<p class="example"><a href="/ascii?code=127">/ascii?code=127</a></p>
<p class="example"><a href="/ts?t=1323782116">/ts?t=1323782116</a></p>
<p class="example"><a href="/country?code=se">/country?code=se</a></p>
<p class="example"><a href="/language?code=se">/language?code=se</a></p>
<p class="example"><a href="/country?name=virgin">/country?name=virgin</a></p>
<p class="example"><a href="/language?name=swedish">/language?name=swedish</a></p>
</div>
</body>
</html>
`