Sitelet https://web.archive.org/web/20210729175617/https://github.com/github/view_component/pull/986
Skip to content
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

Add slot_index method #986

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add slot_index method #986

wants to merge 2 commits into from

Conversation

@dkniffin
Copy link
Contributor

@dkniffin dkniffin commented Jun 26, 2021

Resolves #982

I've taken a first stab at this. @joelhawksley let me know what you think of this. I'd definitely want to add tests and docs, but I want to make sure I'm headed in the right direction first.

@joelhawksley
Copy link
Contributor

@joelhawksley joelhawksley commented Jun 29, 2021

@dkniffin it looks like you're making changes in the right places!

FWIW, I generally prefer to see failing tests before anything else, so we can chat about proposed APIs.

@dkniffin dkniffin force-pushed the dkniffin:component-iterator branch from e634a5f to 1dd4874 Jul 10, 2021
@dkniffin
Copy link
Contributor Author

@dkniffin dkniffin commented Jul 10, 2021

@joelhawksley Alright, I pushed up a commit w/ a failing test (and rebased so it's in the right order). I'm noticing now that the implementation is definitely a bit wrong because there's some test failures. Thoughts?

@@ -250,6 +256,10 @@ def set_slot(slot_name, *args, **kwargs, &block)

if slot_definition[:collection]
@__vc_set_slots[slot_name] ||= []

# set the index to the next index in the array (aka, the current length)
slot.slot_index = @__vc_set_slots[slot_name].length

This comment has been minimized.

@BlakeWilliams

BlakeWilliams Jul 12, 2021
Member

What happens if we sort the collection before rendering?

This comment has been minimized.

@dkniffin

dkniffin Jul 13, 2021
Author Contributor

:/ Yeah, that wouldn't work with the current implementation. I'm not sure if that'd be a common use-case or not though. It's certainly not for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants