Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ There are a few built in functions as well:
* `upper $value` - Uppercase a string.
* `jsonQuery $json $query` - Returns the result of a selection query against a json document.
* `loop` - Create for loops.
* `isStrFullMatch` - Returns true if a string is match another string

### jsonQuery

Expand Down
34 changes: 21 additions & 13 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,29 @@ func loop(args ...int) (<-chan int, error) {
return c, nil
}

func isStrFullMatch(src, dst string) bool {
if src == dst {
return true
}
return false
}

func generateFile(templatePath, destPath string) bool {
tmpl := template.New(filepath.Base(templatePath)).Funcs(template.FuncMap{
"contains": contains,
"exists": exists,
"split": strings.Split,
"replace": strings.Replace,
"default": defaultValue,
"parseUrl": parseUrl,
"atoi": strconv.Atoi,
"add": add,
"isTrue": isTrue,
"lower": strings.ToLower,
"upper": strings.ToUpper,
"jsonQuery": jsonQuery,
"loop": loop,
"contains": contains,
"exists": exists,
"split": strings.Split,
"replace": strings.Replace,
"default": defaultValue,
"parseUrl": parseUrl,
"atoi": strconv.Atoi,
"add": add,
"isTrue": isTrue,
"lower": strings.ToLower,
"upper": strings.ToUpper,
"jsonQuery": jsonQuery,
"loop": loop,
"isStrFullMatch": isStrFullMatch,
})

if len(delims) > 0 {
Expand Down