Skip to content

Commit

Permalink
feat: add jsonEscape
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed May 11, 2022
1 parent 96fd741 commit 3e4373d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/cli/funcs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"encoding/json"
"fmt"
"math"
"os"
Expand Down Expand Up @@ -46,6 +47,13 @@ func init() {
t.ClearRows()
return t
}
funcs["jsonEscape"] = func(i string) string {
b, err := json.Marshal(i)
if err != nil {
panic(err)
}
return string(b[1 : len(b)-1])
}
}

func quote(str ...interface{}) string {
Expand Down

0 comments on commit 3e4373d

Please sign in to comment.