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

Make template locals available as a hash to the template itself #18962

Closed
dhh opened this issue Feb 16, 2015 · 3 comments
Closed

Make template locals available as a hash to the template itself #18962

dhh opened this issue Feb 16, 2015 · 3 comments
Milestone

Comments

@dhh
Copy link
Member

dhh commented Feb 16, 2015

This is a common piece of code:

# Template 1
<%= render 'some/partial', magic: variable %>

# Template 2
<%= render 'some/partial' %>

# some/partial
<%= defined?(magic) ? magic : '' %>

That defined? check is pretty gross. I'd much rather be able to do:

# some/partial
<%= locals[:magic] %>
@dhh dhh added the actionview label Feb 16, 2015
@dhh dhh added this to the 5.0.0 milestone Feb 16, 2015
@dhh
Copy link
Member Author

dhh commented Feb 16, 2015

These fucking Rails people have thought of everything! local_assigns is exactly this and already available. TIL!

@dhh dhh closed this as completed Feb 16, 2015
@cristianbica
Copy link
Member

This is actually an kind of private API as it's a local variable eval'ed here. There's an isssue (#15700) to document it. Probably the naming local_assigns will remain

@ondrek
Copy link

ondrek commented Feb 20, 2015

👊 🐴 brohoof

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

No branches or pull requests

4 participants