You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started to migrate own ruby-view-component-classes, with similar approach of ViewComponent, as ViewComponent solved several things pretty well.
But when it comes to the recursive rendering, I cannot find a solution unfortunately.. first thing was, that I thought I found a bug, but indeed it looks like I'm trying it wrong or it's not possible and I should find the proper way.
Let's say I have two Components: TreeComponent and TreeNodeComponent.
I also have a mixin module, which is included in both components, which just defines the layer slots:
renders_many :nodes, 'TreeNode'
So each "layer" has several sub nodes. It seems theres no problem with it so far.
In the haml view it looks similar to this:
= render TreeComponent.new(title: '..') do |tree|
= tree.node(title: '...', icon: '') do
...
= tree.node(title: '...', icon: '') do
...
The problem starts, when I want to change or access the node properties, as the node instance is not populated, like it is on the root TreeComponent, where I can reference the tree within the block.
= render TreeComponent.new(title: '..') do |tree|
= tree.node(title: '...', icon: '') do |node|
- node.changable_url = url_for(....)
= node.node(title: '...', icon: '') do |node_level_2|
...
Why isnt the built Component-Instance propagated to the corresponding slot? Am I missing something, or am I framed wrong, with the bias to "just migrate" our components?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I started to migrate own ruby-view-component-classes, with similar approach of ViewComponent, as ViewComponent solved several things pretty well.
But when it comes to the recursive rendering, I cannot find a solution unfortunately.. first thing was, that I thought I found a bug, but indeed it looks like I'm trying it wrong or it's not possible and I should find the proper way.
Let's say I have two Components: TreeComponent and TreeNodeComponent.
I also have a mixin module, which is included in both components, which just defines the layer slots:
renders_many :nodes, 'TreeNode'
So each "layer" has several sub nodes. It seems theres no problem with it so far.
In the haml view it looks similar to this:
The problem starts, when I want to change or access the node properties, as the node instance is not populated, like it is on the root TreeComponent, where I can reference the tree within the block.
Why isnt the built Component-Instance propagated to the corresponding slot? Am I missing something, or am I framed wrong, with the bias to "just migrate" our components?
Thanks alot!
Beta Was this translation helpful? Give feedback.
All reactions