Replies: 1 comment 2 replies
-
Can't offer much advice in this direction tbh, I've never done/needed to do such complex component nesting. I've used Maizzle in projects that compiled over 100 templates (many of them sharing multiple, sometimes identical, sections) but never needed to extract more than a header/footer/hero/button to components that I didn't have to nest. So my first concern here would be if I'm not perhaps doing premature abstractions - do you really need everything as a nested component? From my experience I almost never had to nest components - just add them here and there throughout the template. Not saying you shouldn't do it, this is just my experience. That being said, Components in Maizzle are not that advanced right now (see #397 (comment)) - my advice is to think of them more like 'includes' and not like how you'd use them in something like Vue for example. Maybe I should have named them Modules, after
See #369
We do say you can extract CSS components, but not that you should 🙂 P.S.: also have a look at extending templates - might be of use in your case. |
Beta Was this translation helpful? Give feedback.
-
I'm building an email template framework for my organization. And the documentation states that repetitive code should be extracted in to components.
@cossssmin Can you guide me on what is possible / best practice with Maizzle today for code reuse?
I've tried the approach ...
I'm having problems with the nested components. For the inner most component to be generic and reusable local data needs to be passed from card-content to the button. But this is failing to render in random ways when we pass local data to a component that is nested in another component (compilation sometimes fails to resolve a component to it's markup and just includes the component tag in the final markup). I've found other issues hinting that this is a bug caused by one of the dependencies of Maizzle.
So, using the hierarchy above as an example, the best we can do now is to nest components down to the first "stateful" component" and there reference global data from the layout (defined via a front matter or configuration file). Right?
Using the hierarchy above I would need to duplicate code for "button" to include it in different types of "card-content" with the correct reference to global data. Right?
Any hints on how to use the framework as intended for reusable abstractions is appreciated!
Thanks for making Maizzle available for us to try and use!
Beta Was this translation helpful? Give feedback.
All reactions