PrivateGER
3 years ago
1 changed files with 6 additions and 44 deletions
@ -1,58 +1,20 @@ |
|||||
package PageHandlers |
package PageHandlers |
||||
|
|
||||
import ( |
import ( |
||||
|
"embed" |
||||
_ "embed" |
_ "embed" |
||||
"fmt" |
|
||||
"html/template" |
"html/template" |
||||
) |
) |
||||
|
|
||||
//go:embed templates/index.html
|
//go:embed templates
|
||||
var indexTmplSource string |
var templateFS embed.FS |
||||
|
|
||||
//go:embed templates/view.html
|
|
||||
var viewTmplSource string |
|
||||
|
|
||||
//go:embed templates/search.html
|
|
||||
var searchTmplSource string |
|
||||
|
|
||||
//go:embed templates/base.html
|
|
||||
var baseTmplSource string |
|
||||
|
|
||||
var tmpl map[string]*template.Template |
var tmpl map[string]*template.Template |
||||
|
|
||||
func init() { |
func init() { |
||||
tmpl = make(map[string]*template.Template) |
tmpl = make(map[string]*template.Template) |
||||
|
|
||||
var err error |
tmpl["index.html"] = template.Must(template.ParseFS(templateFS, "templates/index.html", "templates/base.html")) |
||||
tmpl["index.html"] = template.New("index.html") |
tmpl["search.html"] = template.Must(template.ParseFS(templateFS, "templates/search.html", "templates/base.html")) |
||||
tmpl["index.html"], err = tmpl["index.html"].Parse(baseTmplSource) |
tmpl["view.html"] = template.Must(template.ParseFS(templateFS, "templates/view.html", "templates/base.html")) |
||||
if err != nil { |
|
||||
fmt.Println(err) |
|
||||
} |
|
||||
tmpl["index.html"], err = tmpl["index.html"].Parse(indexTmplSource) |
|
||||
if err != nil { |
|
||||
fmt.Println(err) |
|
||||
} |
|
||||
|
|
||||
fmt.Println(tmpl["index.html"].Name()) |
|
||||
|
|
||||
tmpl["search.html"] = template.New("search.html") |
|
||||
tmpl["search.html"], err = tmpl["search.html"].Parse(searchTmplSource) |
|
||||
if err != nil { |
|
||||
fmt.Println(err) |
|
||||
} |
|
||||
tmpl["search.html"], err = tmpl["search.html"].Parse(baseTmplSource) |
|
||||
if err != nil { |
|
||||
fmt.Println(err) |
|
||||
} |
|
||||
|
|
||||
tmpl["view.html"] = template.New("view.html") |
|
||||
tmpl["view.html"], err = tmpl["view.html"].Parse(viewTmplSource) |
|
||||
if err != nil { |
|
||||
fmt.Println(err) |
|
||||
} |
|
||||
tmpl["view.html"], err = tmpl["view.html"].Parse(baseTmplSource) |
|
||||
if err != nil { |
|
||||
fmt.Println(err) |
|
||||
} |
|
||||
} |
} |
||||
|
Loading…
Reference in new issue