MCPcopy Create free account
hub / github.com/CloudyKit/jet / init

Function init

eval_test.go:73–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71}
72
73func init() {
74 stdSet.Funcs(template.FuncMap{"dummy": dummy})
75 _, err := stdSet.Parse(`
76 {{define "actionNode_dummy"}}hello {{dummy "WORLD"}}{{end}}
77 {{define "noAllocFn"}}hello {{ "José" }} {{1}} {{ "José" }} {{end}}
78 {{define "rangeOverUsers_Set"}}{{range $index,$val := . }}{{$index}}:{{$val.Name}}-{{$val.Email}}{{end}}{{end}}
79 {{define "rangeOverUsers"}}{{range . }}{{.Name}}-{{.Email}}{{end}}{{end}}
80 `)
81 if err != nil {
82 println(err.Error())
83 }
84
85 JetTestingSet.AddGlobal("dummy", dummy)
86 JetTestingSet.AddGlobalFunc("customFn", func(args Arguments) reflect.Value {
87 args.RequireNumOfArguments("customFn", 1, 1)
88 return args.Get(0)
89 })
90
91 JetTestingLoader.Set("actionNode_dummy", `hello {{dummy("WORLD")}}`)
92 JetTestingLoader.Set("noAllocFn", `hello {{ "José" }} {{1}} {{ "José" }}`)
93 JetTestingLoader.Set("rangeOverUsers", `{{range .}}{{.Name}}-{{.Email}}{{end}}`)
94 JetTestingLoader.Set("rangeOverUsers_Set", `{{range index,user:= . }}{{index}}{{user.Name}}-{{user.Email}}{{end}}`)
95 JetTestingLoader.Set("BenchNewBlock", "{{ block col(md=12,offset=0) }}\n<div class=\"col-md-{{md}} col-md-offset-{{offset}}\">{{ yield content }}</div>\n\t\t{{ end }}\n\t\t{{ block row(md=12) }}\n<div class=\"row {{md}}\">{{ yield content }}</div>\n\t\t{{ content }}\n<div class=\"col-md-1\"></div>\n<div class=\"col-md-1\"></div>\n<div class=\"col-md-1\"></div>\n\t\t{{ end }}\n\t\t{{ block header() }}\n<div class=\"header\">\n\t{{ yield row() content}}\n\t\t{{ yield col(md=6) content }}\n{{ yield content }}\n\t\t{{end}}\n\t{{end}}\n</div>\n\t\t{{content}}\n<h1>Hey</h1>\n\t\t{{ end }}")
96 JetTestingLoader.Set("BenchCustomRanger", "{{range .}}{{.Name}}{{end}}")
97 JetTestingLoader.Set("BenchIntsRanger", "{{range ints(0, .)}} {{end}}")
98 JetTestingLoader.Set("BenchCustomRender", "{{range k, v := ints(0, .N)}}{{.Field}}{{end}}")
99 JetTestingLoader.Set("BenchCallCustomFn", "{{range ints(0, .N)}}{{customFn(.)}}{{end}}")
100 JetTestingLoader.Set("BenchExecPipeline", "{{range ints(0, .N)}}{{. | customFn}}{{end}}")
101}
102
103func RunJetTest(t *testing.T, variables VarMap, context interface{}, testName, testContent, testExpected string) {
104 if testContent != "" {

Callers

nothing calls this directly

Calls 6

ParseMethod · 0.80
AddGlobalMethod · 0.80
AddGlobalFuncMethod · 0.80
RequireNumOfArgumentsMethod · 0.80
GetMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…