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

Comments

Projects
None yet
4 participants
@dhh
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

This comment has been minimized.

Show comment
Hide comment
@dhh

dhh Feb 16, 2015

Member

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

Member

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 Feb 16, 2015

@cristianbica

This comment has been minimized.

Show comment
Hide comment
@cristianbica

cristianbica Feb 17, 2015

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

Member

cristianbica commented Feb 17, 2015

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

This comment has been minimized.

Show comment
Hide comment
@ondrek

ondrek Feb 20, 2015

👊 🐴 brohoof

ondrek commented Feb 20, 2015

👊 🐴 brohoof

@rafaelfranca rafaelfranca modified the milestones: 5.0.0 [temp], 5.0.0 Dec 30, 2015

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