aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_lua.go
diff options
context:
space:
mode:
authorLibravatarLibravatar Simon Ser <[email protected]> 2019-12-11 15:08:31 +0100
committerLibravatarLibravatar Simon Ser <[email protected]> 2019-12-11 15:08:31 +0100
commit1b5bc568fb638314b62ea3d6635de56109680da9 (patch)
treec9288cab963085114b6e54fcf5de7c08c043f8b5 /plugin_lua.go
parentfec8caa3cdea5218cbde9c95e8600ad46a8f5fc8 (diff)
downloadalps-1b5bc568fb638314b62ea3d6635de56109680da9.tar.gz
alps-1b5bc568fb638314b62ea3d6635de56109680da9.tar.bz2
alps-1b5bc568fb638314b62ea3d6635de56109680da9.zip
Allow plugins to provide their own templates
Diffstat (limited to 'plugin_lua.go')
-rw-r--r--plugin_lua.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/plugin_lua.go b/plugin_lua.go
index 372c341..9354de7 100644
--- a/plugin_lua.go
+++ b/plugin_lua.go
@@ -86,8 +86,20 @@ func (p *luaPlugin) Inject(name string, data interface{}) error {
return nil
}
-func (p *luaPlugin) Filters() template.FuncMap {
- return p.filters
+func (p *luaPlugin) LoadTemplate(t *template.Template) error {
+ t.Funcs(p.filters)
+
+ paths, err := filepath.Glob(filepath.Dir(p.filename) + "/public/*.html")
+ if err != nil {
+ return err
+ }
+ if len(paths) > 0 {
+ if _, err := t.ParseFiles(paths...); err != nil {
+ return err
+ }
+ }
+
+ return nil
}
func (p *luaPlugin) SetRoutes(group *echo.Group) {
@@ -136,7 +148,7 @@ func loadLuaPlugin(filename string) (*luaPlugin, error) {
}
func loadAllLuaPlugins(log echo.Logger) ([]Plugin, error) {
- filenames, err := filepath.Glob("plugins/*.lua")
+ filenames, err := filepath.Glob(pluginDir + "/*/main.lua")
if err != nil {
return nil, fmt.Errorf("filepath.Glob failed: %v", err)
}