Indexof substring in hugo

There wouldn’t be an easy way that I’m not finding in the docs by chance. Or an easy way to implement the go version IndexOf(a,b)

Thanks

I guess you could

{{ $parts := strings.Split $a $b }}
{{ $idx := -1 }}
{{ with $parts }}
  {{ $idx = (sub (len (index $parts 0) 1) }}
{{ end }}

Which is a mouthful, and I’m sure there must be a typo somewhere…

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.