Skip to content

Commit

Permalink
cmd/webhook: add json func for tsc files
Browse files Browse the repository at this point in the history
  • Loading branch information
rjeczalik committed Jul 24, 2017
1 parent 5589da9 commit 5fec87e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/internal/tsc/tsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tsc

import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -147,6 +148,16 @@ func (s *Script) funcs() template.FuncMap {
}
return ""
},
"json": func(v interface{}) (string, error) {
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
enc.SetIndent("", "\t")
enc.SetEscapeHTML(false)
if err := enc.Encode(v); err != nil {
return "", err
}
return buf.String(), nil
},
"logf": func(format string, v ...interface{}) string {
if format == "" {
return ""
Expand Down

0 comments on commit 5fec87e

Please sign in to comment.