aboutsummaryrefslogtreecommitdiff
path: root/template.go
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-12-09 16:02:12 +0100
committerSimon Ser <contact@emersion.fr>2019-12-09 16:05:40 +0100
commit4f74722c14d18e78e172825961d7a65d25b41d3f (patch)
tree7ffe867986e26e4b5f4a27cb061030e2337efa96 /template.go
parenta176409933129eccdcf06ef131c76aee497b53aa (diff)
downloadalps-4f74722c14d18e78e172825961d7a65d25b41d3f.tar.gz
alps-4f74722c14d18e78e172825961d7a65d25b41d3f.zip
Add basic support for plugins
Diffstat (limited to 'template.go')
-rw-r--r--template.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/template.go b/template.go
index f12e2ec..a4c3ee0 100644
--- a/template.go
+++ b/template.go
@@ -1,6 +1,7 @@
package koushin
import (
+ "fmt"
"html/template"
"io"
"net/url"
@@ -13,7 +14,16 @@ type tmpl struct {
t *template.Template
}
-func (t *tmpl) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
+func (t *tmpl) Render(w io.Writer, name string, data interface{}, ectx echo.Context) error {
+ // ectx is the raw *echo.context, not our own *context
+ ctx := ectx.Get("context").(*context)
+
+ for _, plugin := range ctx.server.plugins {
+ if err := plugin.Render(name, data); err != nil {
+ return fmt.Errorf("failed to run plugin '%v': %v", plugin.Name(), err)
+ }
+ }
+
return t.t.ExecuteTemplate(w, name, data)
}