Problem using a variable in WHERE

Hi. I have struggled with this for some hours, and it’s about time to ask for help :exploding_head:

Trying to create a SLICE of matching strings, but have som issues with the WHERE function.

This works fine:

{{ $rentals := where .Site.RegularPages "" "eq" "eiendommer/" }}

This dont work:

{{ $rentals := where .Site.RegularPages "" "eq" .File.Path }}

If I print .File.Path I get “eiendommer/”

So I cant figure out why it works with a basic string, and not with the variable with the identical string.

I have also tried this with no luck:

{{ $rentals := where .Site.RegularPages "" "eq" (string .File.Path) }}

This is now working.

Could not use .File.Path because the output gets wrong. So instead I had to use the .RelPermalink Here is the solution:

{{ $thispage := .RelPermalink | strings.TrimLeft "/" | strings.TrimRight "/" }}
{{ $rentals := where .Site.RegularPages "" (printf "%s.%s" $thispage "md") }}

You have to do this instead:

{{ range .Site.RegularPages }}
  {{ if eq .Path }}
  {{ end }}
{{ end }}

Note that you can use .Path instead of .File.Path.

Thanx, but that did not work.

The problem is the seperator \ instead og /. But I guess by using REPLACE your solution would work fine, and is way more elegant than mine.

The seperator is generated by when using their “SELECT” with “DOCUMENT REFERENCE” option.