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

[Fix #49761] allow an injection of collection locals. #49780

Closed
wants to merge 4 commits into from

Conversation

HolyWalley
Copy link
Contributor

@HolyWalley HolyWalley commented Oct 25, 2023

Motivation / Background

Discussed in this issue #49761

Detail

This Pull Request allows ActionView::Template#render method to accept an array injected_locals, which is an array of keys of locals that were inejected by rails, for example ActionView::Renderer::CollectionRenderer injects *_counter and *_iteration locals. With those values render method can filter out locals that were injected, but not specified in strict locals to prevent errors described in referring issue.

Additional information

I'm not sure if I should add anything to changelog or documentation. From one side it's an internal change, from the other some docs might be updated. So, please, let me know if I should add any of the info to changelog/docs.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@rails-bot rails-bot bot added the actionview label Oct 25, 2023
casperisfine pushed a commit to Shopify/rails that referenced this pull request Oct 25, 2023
Fix: rails#49780
Fix: rails#49761

`CollectionRenderer` implictly inject `<name>_counter` and `<name>_iteration`
locals, but in the overwhelming majority of cases they aren't used.

So when the rendered template has strict locals we shouldn't require
these to be declared, and if they aren't we should simply not pass them.

Co-Authored-By: HolyWalley <yakau@hey.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants