mark2web/helper/template_filters.go

22 lines
457 B
Go
Raw Normal View History

2019-02-27 15:58:10 +01:00
package helper
import (
"github.com/flosch/pongo2"
_ "github.com/flosch/pongo2-addons"
)
func init() {
pongo2.ReplaceFilter("markdown", MarkdownFilter)
}
// MarkdownFilter is a pongo2 filter, which converts markdown to html
func MarkdownFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
2019-02-28 15:40:06 +01:00
return pongo2.AsSafeValue(
string(
renderMarkdown(
[]byte(in.String()),
currentPathConfig.Markdown,
))),
nil
2019-02-27 15:58:10 +01:00
}