Update go tmpl name
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (app *application) VirtualTerminal(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
if err := app.renderTemplate(w, r, "terminal", nil); err != nil {
|
||||
app.errorLog.Println(err)
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func (app *application) renderTemplate(
|
||||
) error {
|
||||
var t *template.Template
|
||||
var err error
|
||||
templateToRender := fmt.Sprintf("templates/%s.page.tmpl", page)
|
||||
templateToRender := fmt.Sprintf("templates/%s.page.gohtml", page)
|
||||
|
||||
_, templateInMap := app.templateCache[templateToRender]
|
||||
|
||||
@ -79,15 +79,15 @@ func (app *application) parseTemplate(
|
||||
// build partials
|
||||
if len(partials) > 0 {
|
||||
for i, x := range partials {
|
||||
partials[i] = fmt.Sprintf("tempaltes/%s.partial.tmpl", x)
|
||||
partials[i] = fmt.Sprintf("tempaltes/%s.partial.gohtml", x)
|
||||
}
|
||||
t, err = template.New(fmt.Sprintf("%s.page.tmpl", page)).
|
||||
t, err = template.New(fmt.Sprintf("%s.page.gohtml", page)).
|
||||
Funcs(functions).
|
||||
ParseFS(templateFS, "templates/base.layout.tmpl", strings.Join(partials, ","), templateToRender)
|
||||
ParseFS(templateFS, "templates/base.layout.gohtml", strings.Join(partials, ","), templateToRender)
|
||||
} else {
|
||||
t, err = template.New(fmt.Sprintf("%s.page.tmpl", page)).
|
||||
t, err = template.New(fmt.Sprintf("%s.page.gohtml", page)).
|
||||
Funcs(functions).
|
||||
ParseFS(templateFS, "templates/base.layout.tmpl", templateToRender)
|
||||
ParseFS(templateFS, "templates/base.layout.gohtml", templateToRender)
|
||||
}
|
||||
if err != nil {
|
||||
app.errorLog.Println(err)
|
||||
|
30
cmd/web/templates/base.layout.gohtml
Normal file
30
cmd/web/templates/base.layout.gohtml
Normal file
@ -0,0 +1,30 @@
|
||||
{{ define "base" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Bootstrap demo</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
||||
crossorigin="anonymous">
|
||||
<title>
|
||||
{{ block "title" . }}
|
||||
{{ end }}
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col">{{ block "content" . }} {{ end }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||
crossorigin="anonymous"></script>
|
||||
{{ block "js" . }}
|
||||
{{ end }}
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
@ -1,3 +0,0 @@
|
||||
{{define "base"}}
|
||||
|
||||
{{end}}
|
9
cmd/web/templates/terminal.page.gohtml
Normal file
9
cmd/web/templates/terminal.page.gohtml
Normal file
@ -0,0 +1,9 @@
|
||||
{{ template "base" . }}
|
||||
{{ define "title" }}
|
||||
Virtual Terminal
|
||||
{{ end }}
|
||||
{{ define "content" }}
|
||||
<h2>Virtual Terminal</h2>
|
||||
{{ end }}
|
||||
{{ define "js" }}
|
||||
{{ end }}
|
Reference in New Issue
Block a user