Skip to content

collections.Apply cannot handle funcs that takes reflect.Value as arg #13418

@irkode

Description

@irkode

looks like the internal functions cannot be used for apply

this works:

$s := slice "hello" "world"

apply $s "strings.FirstUpper" "." -> [%!t(string=Hello) %!t(string=World)]
apply $s "add" "." ", five" -> [%!t(string=hello, five) %!t(string=world, five)]

not "hello" -> false
len "hello" -> %!t(int=5)

these fail

apply (slice "hello) "not" "." 
apply (slice "hello) "len" "." 

Error: error building site: render: failed to render pages:
  render of "C:/_repos/github/clone/issue-2906-return-values/content/_index.md" failed:
  "C:\_repos\github\clone\issue-2906-return-values\layouts\_default\home.html:20:17":
  execute of template failed: template: _default/home.html:20:17: 
  executing "main" at <apply (slice "hello") "not" ".">: 
  error calling apply: called apply using string as type reflect.Value

Hugo 0.144.1 also fails in 128.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions