Revert "tpl: Update Jsonify to return pretty-print output"

This reverts commit 5a52cd5f92.

Closes #5394
This commit is contained in:
Bjørn Erik Pedersen 2018-11-02 19:03:48 +01:00
parent 486bc46a52
commit 4f3c095963
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
4 changed files with 5 additions and 5 deletions

View file

@ -1,7 +1,7 @@
---
title: jsonify
linktitle: jsonify
description: Encodes a given object to JSON, returning pretty printed output.
description: Encodes a given object to JSON.
godocref:
date: 2017-02-01
publishdate: 2017-02-01

View file

@ -50,9 +50,9 @@ func (ns *Namespace) Base64Encode(content interface{}) (string, error) {
return base64.StdEncoding.EncodeToString([]byte(conv)), nil
}
// Jsonify encodes a given object to JSON, returning pretty printed output.
// Jsonify encodes a given object to JSON.
func (ns *Namespace) Jsonify(v interface{}) (template.HTML, error) {
b, err := json.MarshalIndent(v, "", " ")
b, err := json.Marshal(v)
if err != nil {
return "", err
}

View file

@ -88,7 +88,7 @@ func TestJsonify(t *testing.T) {
v interface{}
expect interface{}
}{
{[]string{"a", "b"}, template.HTML("[\n \"a\",\n \"b\"\n]")},
{[]string{"a", "b"}, template.HTML(`["a","b"]`)},
{tstNoStringer{}, template.HTML("{}")},
{nil, template.HTML("null")},
// errors

View file

@ -47,7 +47,7 @@ func init() {
ns.AddMethodMapping(ctx.Jsonify,
[]string{"jsonify"},
[][2]string{
{`{{ (slice "A" "B" "C") | jsonify }}`, "[\n \"A\",\n \"B\",\n \"C\"\n]"},
{`{{ (slice "A" "B" "C") | jsonify }}`, `["A","B","C"]`},
},
)