32 lines
783 B
Go
32 lines
783 B
Go
package mark2web
|
|
|
|
import (
|
|
"gitbase.de/apairon/mark2web/pkg/webrequest"
|
|
"github.com/flosch/pongo2"
|
|
)
|
|
|
|
// RequestFn will make a web request and returns map[string]interface form pongo2
|
|
func RequestFn(url *pongo2.Value, args ...*pongo2.Value) *pongo2.Value {
|
|
u := url.String()
|
|
return pongo2.AsValue(webrequest.GetJSON(u))
|
|
}
|
|
|
|
// RenderFn renders a pongo2 template with additional context
|
|
func RenderFn(templateFilename, subDir, ctx *pongo2.Value, param ...*pongo2.Value) *pongo2.Value {
|
|
dataMapKey := ""
|
|
body := ""
|
|
|
|
for i, p := range param {
|
|
switch i {
|
|
case 0:
|
|
dataMapKey = p.String()
|
|
case 1:
|
|
body = p.String()
|
|
}
|
|
}
|
|
|
|
CurrentTreeNode.addSubNode(templateFilename.String(), subDir.String(), "", ctx.Interface(), dataMapKey, body, true)
|
|
|
|
return pongo2.AsValue(nil)
|
|
}
|