tpl/transform: Add template func for TOML/JSON/YAML docs examples conversion

Usage:

```html
{{ "title = \"Hello World\"" | transform.Remarshal "json" | safeHTML }}
```

Fixes #4389
This commit is contained in:
Bjørn Erik Pedersen
2018-02-09 09:21:46 +01:00
parent 2e95ec6844
commit d382502d6d
4 changed files with 265 additions and 0 deletions

View File

@@ -88,6 +88,13 @@ func init() {
},
)
ns.AddMethodMapping(ctx.Remarshal,
nil,
[][2]string{
{`{{ "title = \"Hello World\"" | transform.Remarshal "json" | safeHTML }}`, "{\n \"title\": \"Hello World\"\n}\n"},
},
)
return ns
}