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

@@ -465,3 +465,9 @@ func DiffStringSlices(slice1 []string, slice2 []string) []string {
return diffStr
}
// DiffString splits the strings into fields and runs it into DiffStringSlices.
// Useful for tests.
func DiffStrings(s1, s2 string) []string {
return DiffStringSlices(strings.Fields(s1), strings.Fields(s2))
}