Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
irkode opened this issue Feb 18, 2025 · 0 comments
Open

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

irkode opened this issue Feb 18, 2025 · 0 comments

Comments

@irkode
Copy link

irkode commented Feb 18, 2025

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

@bep bep changed the title collections.apply cannot handle "go template" functions collections.Apply cannot handle "go template" functions Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant