github.com/coveo/gotemplate@v2.7.7+incompatible/template/razor_repl_autowrap.go (about) 1 package template 2 3 import ( 4 "fmt" 5 6 "github.com/coveo/gotemplate/utils" 7 ) 8 9 func autoWrap(repl replacement, match string) string { 10 matches, _ := utils.MultiMatch(match, repl.re) 11 before := String(matches["before"]) 12 context := String(matches["context"]) 13 context, strings := context.Protect() 14 args := context.SelectContext(1, "(", ")") 15 if args == "" { 16 log.Warningf("Missing closing parenthesis in %s%s", matches["func"], context.RestoreProtected(strings)) 17 return match 18 } 19 after := context[len(args):] 20 return fmt.Sprintf("@%s%sjoin(\"%s\", formatList(\"%s%%v%s\", %s)", 21 matches["nl"], 22 matches["reduce"], 23 iif(matches["nl"] != "", "\\n", ""), 24 before.Escape(), 25 after.RestoreProtected(strings).Escape(), 26 args.RestoreProtected(strings)[1:], 27 ) 28 }