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 "Params.property" "eq" "eiendommer/eiendom1.md" }}

This dont work:

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

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

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 "Params.property" "eq" (string .File.Path) }}

UPDATE
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 "Params.property" (printf "%s.%s" $thispage "md") }}

You have to do this instead:

{{ range .Site.RegularPages }}
  {{ if eq .Params.property .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 Forestry.io when using their “SELECT” with “DOCUMENT REFERENCE” option.