1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-09-13 17:46:23 -07:00

Add template loading to the templates manage action

This commit is contained in:
Eggbertx 2023-12-21 15:55:29 -08:00
parent a8436c5ee4
commit 7e07e24f16
6 changed files with 87 additions and 55 deletions

View file

@ -1,6 +1,9 @@
package gctemplates
import (
"html/template"
"path"
lua "github.com/yuin/gopher-lua"
luar "layeh.com/gopher-luar"
)
@ -14,7 +17,7 @@ func PreloadModule(l *lua.LState) int {
for i := 0; i < l.GetTop(); i++ {
tmplPaths = append(tmplPaths, l.CheckString(i+1))
}
tmpl, err := loadTemplate(tmplPaths...)
tmpl, err := template.New(path.Base(tmplPaths[0])).Funcs(funcMap).ParseFiles(tmplPaths...)
l.Push(luar.New(l, tmpl))
l.Push(luar.New(l, err))
return 2