Render children node views inside it's parent node view

(Buwaro) #1

Is There a PushType way to render a view of a node inside another node’s view?
I’d like to do this so that an admin can add different parts to a page and order them how they want

For now, I solved the problem by creating a partials for every child node:


class Page < PushType::Node
  has_child_nodes :all


<% @node.children.each do |child | %>
  <%= render "nodes/_#{}", node: child %>
<% end %>

app/views/nodes/video.html.erb (so that the preview still works)

<%= render "nodes/_video", node: @node %>


# The html that was in the video view with the variable names changed from '@node' to 'node'
  • other nodes like video for ex: items, photos, …

But maybe it would be easier with something like a render_node() helper?