32 lines
795 B
Go
32 lines
795 B
Go
|
package mark2web
|
||
|
|
||
|
import (
|
||
|
"gitbase.de/apairon/mark2web/helper"
|
||
|
"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(helper.JSONWebRequest(u))
|
||
|
}
|
||
|
|
||
|
// RenderFn renders a pongo2 template with additional context
|
||
|
func RenderFn(templateFilename, outDir, 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()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Add2Nav(CurrentTreeNode, CurrentPathConfig, templateFilename.String(), outDir.String(), "", ctx.Interface(), dataMapKey, body, true)
|
||
|
|
||
|
return pongo2.AsValue(nil)
|
||
|
}
|