mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add base/footer/header templates and use them on home route
This commit is contained in:
parent
743cc82a87
commit
65e760454c
5 changed files with 35 additions and 12 deletions
|
@ -167,7 +167,13 @@ type homeRouteData struct {
|
|||
}
|
||||
|
||||
func (app *application) homeRoute(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||
t, err := template.ParseFiles("./web/templates/home.page.gohtml")
|
||||
t, err := template.ParseFiles(
|
||||
"./web/templates/base.template.gohtml",
|
||||
"./web/templates/header.partial.gohtml",
|
||||
"./web/templates/footer.partial.gohtml",
|
||||
"./web/templates/home.page.gohtml",
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
app.Log.Error(err)
|
||||
return
|
||||
|
|
18
web/templates/base.template.gohtml
Normal file
18
web/templates/base.template.gohtml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="width=device-width,initial-scale=1" name="viewport">
|
||||
<title>{{ template "title" . }}</title>
|
||||
<meta property="og:title" content="nourybot - lidl twitch bot">
|
||||
<meta property="og:description" content="nourybot">
|
||||
</head>
|
||||
<header>
|
||||
{{ template "header" .}}
|
||||
</header>
|
||||
<body>
|
||||
{{ template "body" . }}
|
||||
</body>
|
||||
<footer>
|
||||
{{ template "footer" . }}
|
||||
</footer>
|
3
web/templates/footer.partial.gohtml
Normal file
3
web/templates/footer.partial.gohtml
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{define "footer"}}
|
||||
Powered by <a href="https://go.dev/">Go</a>
|
||||
{{end}}
|
3
web/templates/header.partial.gohtml
Normal file
3
web/templates/header.partial.gohtml
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{define "header"}}
|
||||
<h1><a href='/'>nourybot</a></h1>
|
||||
{{end}}
|
|
@ -1,13 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="width=device-width,initial-scale=1" name="viewport">
|
||||
<title>nourybot - lidl twitch bot</title>
|
||||
<meta property="og:title" content="nourybot - lidl twitch bot">
|
||||
<meta property="og:description" content="nourybot">
|
||||
</head>
|
||||
<h1>nourybot</h1>
|
||||
{{define "title"}}nourybot{{end}}
|
||||
{{define "body"}}
|
||||
<p>Channels connected to:</hp>
|
||||
<table>
|
||||
<tr>
|
||||
|
@ -21,5 +13,6 @@
|
|||
<td>{{ .Login }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</table>
|
||||
{{ end }}
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in a new issue