Skip to content

collections.Apply cannot handle "go template" functions #13418

Open
@irkode

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions