From d3e95a66f128dd30f094a69f80b89a166e83259f Mon Sep 17 00:00:00 2001 From: nxshock Date: Sat, 25 Sep 2021 17:24:59 +0500 Subject: [PATCH] Make html templates separate from site files --- templates.go | 8 +++++++- {site => templates}/index.htm | 0 2 files changed, 7 insertions(+), 1 deletion(-) rename {site => templates}/index.htm (100%) diff --git a/templates.go b/templates.go index 8a1a8b3..ff8fbee 100644 --- a/templates.go +++ b/templates.go @@ -1,6 +1,7 @@ package main import ( + "embed" "html/template" log "github.com/sirupsen/logrus" @@ -8,15 +9,20 @@ import ( var templates *template.Template +//go:embed templates/*.htm +var templatesFS embed.FS + func initTemplates() error { log.Debugln("Templates initialization started.") defer log.Debugln("Templates initialization finished.") var err error - templates, err = template.ParseFS(siteFS, "site/index.htm") + templates, err = template.ParseFS(templatesFS, "templates/index.htm") if err != nil { return err } + templatesFS = embed.FS{} + return nil } diff --git a/site/index.htm b/templates/index.htm similarity index 100% rename from site/index.htm rename to templates/index.htm