mirror of
https://github.com/nxshock/simplefileshare.git
synced 2024-11-28 03:21:00 +05:00
Make html templates separate from site files
This commit is contained in:
parent
5d632da771
commit
d3e95a66f1
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"embed"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@ -8,15 +9,20 @@ import (
|
|||||||
|
|
||||||
var templates *template.Template
|
var templates *template.Template
|
||||||
|
|
||||||
|
//go:embed templates/*.htm
|
||||||
|
var templatesFS embed.FS
|
||||||
|
|
||||||
func initTemplates() error {
|
func initTemplates() error {
|
||||||
log.Debugln("Templates initialization started.")
|
log.Debugln("Templates initialization started.")
|
||||||
defer log.Debugln("Templates initialization finished.")
|
defer log.Debugln("Templates initialization finished.")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
templates, err = template.ParseFS(siteFS, "site/index.htm")
|
templates, err = template.ParseFS(templatesFS, "templates/index.htm")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templatesFS = embed.FS{}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user