mirror of
https://github.com/nxshock/promodj.git
synced 2024-11-27 03:01:01 +05:00
Make html templates separate from site files
This commit is contained in:
parent
b0f9ea1f49
commit
379450c70f
13
main.go
13
main.go
@ -1,14 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
var templates *template.Template
|
||||
|
||||
func init() {
|
||||
log.SetFlags(0)
|
||||
@ -36,17 +34,6 @@ func init() {
|
||||
http.DefaultClient.Timeout = 5 * time.Second
|
||||
}
|
||||
|
||||
func initTepmplates() error {
|
||||
var err error
|
||||
|
||||
templates, err = template.ParseFS(siteFS, "site/*.htm")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handleGenres)
|
||||
http.HandleFunc("/genres", handleGenres)
|
||||
|
24
templates.go
Normal file
24
templates.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"html/template"
|
||||
)
|
||||
|
||||
var templates *template.Template
|
||||
|
||||
//go:embed templates/*.htm
|
||||
var templatesFS embed.FS
|
||||
|
||||
func initTepmplates() error {
|
||||
var err error
|
||||
|
||||
templates, err = template.ParseFS(templatesFS, "templates/*.htm")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
templatesFS = embed.FS{}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user