Using a component without render
#415
hangsu
started this conversation in
Component architecture
Replies: 2 comments
-
|
For anyone interested, this pattern has worked well for me: class MainComponent < Phlex::HTML
Accessory = Struct.new(:section_content, :button_content)
def initialize(accessories = [Accessory.new(...), Accessory.new(...)])
@accessories = accessories
end
def template
div do
@accessories.each { |a| section(a) }
end
nav do
@accessories.each { |a| button(a) }
end
end
def section(accessory)
div { accessory.section_content }
end
def button(accessory)
button { accessory.button_content }
end
end |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@hangsu and I already discussed this but in case it helps anyone else, we’re introducing |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I found myself wanting to do something like:
This doesn't work because
@accessorydoesn't have a@_targetwithout beingrendered.Is this something that you would consider supporting?
Beta Was this translation helpful? Give feedback.
All reactions