findRE with parameter - cast to number

Hello,

I’m using findRE to extract content and I will add the parameter for number of results, but I get an type error “wrong type for value; expected int; got string”. I do inside my shortcode:

findRE .mycontent (index .Params 1 | default 1)

but if the parameter 5 is not set, the default part will return the number 1, but if I set my shortcode with

{{< mycommand "some other parameter" 2 >}}

it will return for “index .Params 1” a string value but findRE expected a numerical value, so how can I cast the value to an integer?

Thanks

findRE .mycontent (index .Params 1 | default 1 | int)

But @moorereason: we should handle this better.

Thanks that works well

https://github.com/spf13/hugo/issues/3018

1 Like