-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.go
42 lines (36 loc) · 976 Bytes
/
page.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
package server
import (
_ "embed"
"strings"
)
//go:embed assets/head.html
var headHTML string
//go:embed assets/body.html
var bodyHTML string
//go:embed assets/javascript.js
var javascript string
type page struct {
title string
clientId string
clientKind string
url string
projectName string
devcardName string
body string
}
func (p page) generate() []byte {
html := headHTML
body := bodyHTML
if p.body != "" {
body = p.body
}
html = strings.ReplaceAll(html, "{{body}}", body)
html = strings.ReplaceAll(html, "{{javascript}}", javascript)
html = strings.ReplaceAll(html, "{{title}}", p.title)
html = strings.ReplaceAll(html, "{{clientId}}", p.clientId)
html = strings.ReplaceAll(html, "{{clientKind}}", p.clientKind)
html = strings.ReplaceAll(html, "{{url}}", p.url)
html = strings.ReplaceAll(html, "{{projectName}}", p.projectName)
html = strings.ReplaceAll(html, "{{devcardName}}", p.devcardName)
return []byte(html)
}