1
0
Fork 0
forked from goffee/core

template system

This commit is contained in:
Zeni Kim 2024-09-24 16:12:17 -05:00
parent 711a68699a
commit 1172e23c16
4 changed files with 89 additions and 3 deletions

15
core.go
View file

@ -6,6 +6,7 @@
package core
import (
"embed"
"fmt"
"log"
"net/http"
@ -37,12 +38,15 @@ var mailer *Mailer
var basePath string
var disableEvents bool = false
//go:embed all:template
var resources embed.FS
type configContainer struct {
Request RequestConfig
}
type App struct {
t int // for trancking hooks
t int // for tracking hooks
chain *chain
hooks *Hooks
Config *configContainer
@ -88,11 +92,16 @@ func (app *App) Run(router *httprouter.Router) {
TemplateEnableStr = "false"
}
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
// if enabled, add public path
// if enabled,
if TemplateEnable {
// add public path
publicPath := os.Getenv("TEMPLATE_PUBLIC")
router.ServeFiles("/public/*filepath", http.Dir(publicPath))
// templates
var template = new(Template)
template.NewTemplates(resources)
}
useHttpsStr := os.Getenv("App_USE_HTTPS")