Reusing a "layout" on multiple components #600
-
I tried to look for documentation regarding this, but unfortunately I could not find anything. Imagine that I have multiple Card components, and they should all be rendered within a # component_a.html.slim
h1 Hello A # component_b.html.slim
h1 Hello B I'd like both of them to render: <div class="card">
<h1>Hello ..<h1>
</div> how can I re-use a common layout? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@coorasse thank you for sharing your question! Generally, I'd recommend using a separate component for your "layout" in this case. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer @joelhawksley but I still don't understand how I can re-use it, without duplicating code...maybe inheriting from the same component? |
Beta Was this translation helpful? Give feedback.
@coorasse for example, you might have a
CardContainerComponent
that provides the<div class="card">
. You'd then render that component inside your other components as a wrapper of their HTML.