File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -262,14 +262,13 @@ Returns global value at key.
262262Defines a global function.
263263
264264```
265- funcDefine "name" "{{{ return 0 "Hello World" }}}"
265+ funcDefine "name" `
266+ {{{ return 0 "Hello World" }}}
267+ `
266268```
267269
268270The second argument is the template body, notice the ` {{{ ... }}} ` instead of ` ${{{ ... }}} ` .
269271
270- > [ !WARNING]
271- > You may need to escape some characters like ` " ` with ` \ `
272-
273272Raw output is discarded only output via [ ` return ` ] ( #return ) persists.
274273
275274##### ` return `
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ var funcCallFunc = TemplateFunc{
7474var funcCallWithArgsFunc = TemplateFunc {
7575 Name : "funcCallArgs" ,
7676 Handler : func (context context.TemplateContext , name string , args ... any ) []any {
77- unpackArgs (args ... )
77+ args = unpackArgs (args ... )
7878
7979 outputs , err := funcCall (context , name , args ... )
8080
@@ -86,14 +86,16 @@ var funcCallWithArgsFunc = TemplateFunc{
8686 },
8787}
8888
89- func unpackArgs (args ... any ) {
89+ func unpackArgs (args ... any ) [] any {
9090 if len (args ) == 1 {
9191 inner , ok := args [0 ].([]any )
9292
9393 if ok {
9494 args = inner
9595 }
9696 }
97+
98+ return args
9799}
98100
99101func funcCreate (_ context.TemplateContext , name , tmplBody string ) any {
@@ -187,7 +189,7 @@ var returnNextFunc = TemplateFunc{
187189var returnAllFunc = TemplateFunc {
188190 Name : "returnAll" ,
189191 Handler : func (context context.TemplateContext , callerID string , value ... any ) any {
190- unpackArgs (value ... )
192+ value = unpackArgs (value ... )
191193
192194 fmt .Println (value )
193195
You can’t perform that action at this time.
0 commit comments