Skip to content

Commit

Permalink
[#139] add shellquote and toMinJson template functions
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Jan 7, 2018
1 parent 425fa63 commit 8c7ca38
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion jiracli/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import (
"io/ioutil"
"os"
"path/filepath"
"regexp"
"reflect"
"regexp"
"strconv"
"strings"
"text/template"

yaml "gopkg.in/coryb/yaml.v2"

"github.com/coryb/figtree"
shellquote "github.com/kballard/go-shellquote"
"github.com/mgutz/ansi"
"golang.org/x/crypto/ssh/terminal"
)
Expand Down Expand Up @@ -74,6 +75,16 @@ func TemplateProcessor() *template.Template {
}
return out
},
"shellquote": func(content string) string {
return shellquote.Join(content)
},
"toMinJson": func(content interface{}) (string, error) {
bytes, err := json.Marshal(content)
if err != nil {
return "", err
}
return string(bytes), nil
},
"toJson": func(content interface{}) (string, error) {
bytes, err := json.MarshalIndent(content, "", " ")
if err != nil {
Expand Down

0 comments on commit 8c7ca38

Please sign in to comment.