I have the following parameter in section 1:
foo:
- "item1"
- "item2"
where “item1” etc. may match the title in section 2
I want to range through items in section 2 and find the items in section 1 that are related (via the “foo” param).
How would I make my where statement to accomplish this, being that foo is an array and .Title is a string? It’s quite easy in reverse.
I’ve tried many many variations to convert one side to the other, for example:
where .Site.RegularPages ".Params.foo" .Title
where .Site.RegularPages ".Params.foo" "in" (slice .Title)
etc.
I’ve searched high and low, so at this point wondering if this possible?
Have you tried intersect?
where .Site.RegularPages ".Params.foo" "intersect" (slice .Title)
What you’ve shown above is:
if .Params.foo == .Title
if .Params.foo is contained within .Title
Neither of those constructs make sense
I have tried intersect and am puzzled why it doesn’t work.
I knew the first one didn’t make sense, but thought the second one (“in”) might.
The second one doesn’t make sense to me because I read that as you’re asking if every element of.Params.foo is contained within .Title. You’re essentially asking if A is a subset of B.
I think intersection is what you want to test for, but we may be missing something here in Where implementation.
I’m putting together a test case and will post it.
1 Like
And note in the reverse case “in” works in the reverse case, but not intersect:
where ($section2) ".Title" "in" .Params.foo
Doesn’t sound like that’s the intended use, based on the way you describe it, but it seems that it should work (title in the foo array).
@moorereason I’ve tried a gazillion iterations on this and I don’t think there’s a way to do it. Should I file an issue on this?
@budparr,
A fix for this issue was committed overnight.
1 Like