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 ChildParent helper #849

Merged
merged 2 commits into from Apr 17, 2016
Merged

Add ChildParent helper #849

merged 2 commits into from Apr 17, 2016

Conversation

denisdefreyne
Copy link
Member

@denisdefreyne denisdefreyne commented Apr 17, 2016

This adds #children_of and #parent_of, which works with both legacy and full identifiers. For example:

<%= link_to(parent_of(@item)) %>
<ul>
<% children_of(@item).each do |child| %>
  <li><%= link_to(child[:title], child) %></li>
<% end %>
</ul>

This allows getting rid of the ugly piece of upgrade advice that tells people to replace @item.parent with @items[@item.identifier.to_s.sub(/[^\/]+$/, '').chop + '.*'].

@denisdefreyne denisdefreyne added this to the 4.2 milestone Apr 17, 2016
@denisdefreyne denisdefreyne merged commit 5935762 into master Apr 17, 2016
@denisdefreyne denisdefreyne deleted the child-parent-helper branch April 17, 2016 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant