mjmlio / mjml

MJML: the only framework that makes responsive-email easy
https://mjml.io
MIT License
17.08k stars 960 forks source link

Extend core components #612

Closed hyakki closed 6 years ago

hyakki commented 7 years ago

Hello.

I'm playing a bit with custom components but i have a little issue with it.

Let say i've created a custom component <epic-section>, that is the <mjml-section> base code with some modifications.

How can i tell to core components ( <mjml-column> for example ) it can now be in a parent epic-section and not only in mj-section, mj-group or mj-navbar ?

iRyusa commented 7 years ago

Hi @maximeparisse !

Well, I have no real answer for that, did you try to import mjml-column and push your tagName it to .parentTag ? I think this could work.

In MJML4 this will be way easier to push new dependencies to the core, you'll be able to inject them with a simple API.

hyakki commented 7 years ago

Hummm, thanks for the answer @iRyusa, i will try that even if i'm not really expert with jsx and react components.

By any chance, do you have an approximative release date for mjml4 ?

PS : When you say i should import mjml-column, in which file/step in the process would i be supposed to do that ?

iRyusa commented 7 years ago

Well we're working to get as many components ready to release a minimal beta with base components ( like section column image text divider ... ). So no date yet, but a beta should be available this month ( april ).

Directly in your components, you may have to add the package mjml-column to your package.json

Laslo89 commented 7 years ago

i have the same Problem:

<section>
  <custom-component>
    <mj-text>
      ...
    </mj-text>
  </custom-component>
</section>

is this supposed to be working? The Compiler tells me that it does not work by design:

Line 111 (mj-text) — mj-text cannot be used inside robo-speechbouble, only inside: mj-column, mj-hero-content

Is there a update-save way to extend the parent-tag of a core comp?

iRyusa commented 7 years ago

As said, dependencies are hard coded into components in MJML3. You can try to edit the MjText.parentTag @Laslo89 but I don't know if it works

Note that validation is completely and purely optional, your document will render fine in a skip/soft level.

In MJML 4 it will be completely different, components are independent and you'll have to define dependencies explicitely

kmcb777 commented 6 years ago

should be possible now with mjml-validator/registerDependencies

iRyusa commented 6 years ago

👆 Closing the issue because it's available in the Beta. Feel free to reopen if you have any issue with it !