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

Closed
dhh opened this Issue Feb 16, 2015 · 3 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
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
Contributor

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
ondrek commented Feb 20, 2015

👊 🐴 brohoof

@rafaelfranca rafaelfranca modified the milestone: 5.0.0 [temp], 5.0.0 Dec 30, 2015
@weiqingtoh weiqingtoh referenced this issue in Coursemology/coursemology2 Oct 17, 2016
Merged

Implement submit for publishing #1591

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