-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tpl: intersect needs some love #1952
Comments
The `intersect` function uses `in` to avoid adding duplicates to the resulting set. We were passing `reflect.Value` items when we should have been using `Value.Interface()` to send the actual data structure. This fixes that. See gohugoio#1952
Add initial interface support to the `intersect` template function. This will allow the use of JSON data structures with intersect. I say "initial" because this commit only works when `l1` is an interface. See gohugoio#1952
The `intersect` function uses `in` to avoid adding duplicates to the resulting set. We were passing `reflect.Value` items when we should have been using `Value.Interface()` to send the actual data structure. This fixes that. See #1952
@moorereason @bep is this issue addressed? (I'm looking for things to contribute to, so just want to avoid working on already fixed stuff). |
@robertbasic, I have a fix for the second test. It's in one of my personal branches (8e81d2e). However, there's still a piece missing, which this test will hit: {[]string{"a", "b", "c"}, []interface{}{"a", "b", "b"}, []string{"a", "b"}}, If you want to take my branch as a starting point and finish it out, go for it! I probably won't have time to finish it for a few days. |
This issue has been automatically marked as stale because it has not been commented on for at least four months. The resources of the Hugo team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the If this is a feature request, and you feel that it is still valuable, please open a proposal at https://discuss.gohugo.io/. This issue will automatically be closed in four months if no further activity occurs. Thank you for all your contributions. |
Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't. If this is a bug and you can still reproduce this error on the latest If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. |
I think I've ran into this issue. When trying to implement related content functionality I thought I'd be able to write:
However, this yields upon closer inspection ( .Params.contexts = while $.Scratch.Get "context" = Anyone know of a work around? |
For the record, I suspect this was happening because I was populating I worked around it by giving up on normalizing a single value into an array of one value, instead branching into a conditional and using
Note: "contexts" instead of "context" in the else branch. Ugly, but it works. |
I'm experiencing this issue, but
Expected behaviour: $c is Any ideas? |
The `intersect` function uses `in` to avoid adding duplicates to the resulting set. We were passing `reflect.Value` items when we should have been using `Value.Interface()` to send the actual data structure. This fixes that. See gohugoio#1952
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The following test cases fail when added to
tpl/template_funcs_test.go:TestIntersect
:Test results:
Regarding test 0,
in
is used byintersect
to avoid adding duplicates to the new set. In this case,in
is receiving areflect.Value
struct, but thereflect.Struct
case is not handled byin
.Regarding test 1,
intersect
does not handle thereflect.Interface
case. See Questions about "intersect" function forum discussion.Tests were done in Go 1.6 and Hugo HEAD.
The text was updated successfully, but these errors were encountered: