ls-age / svelte-mail

Renders Svelte components for emails. Inlines styles and renders additional plain text version.
50 stars 0 forks source link

Can you use this with mjml? #13

Open jamauro opened 4 years ago

jamauro commented 4 years ago

Would be great to use this with https://github.com/mjmlio/mjml. Is it possible?

LukasHechenberger commented 4 years ago

Well I guess it should be pretty easy to write a svelte preprocessor that compiles mjml to html in your templates, did you try to do so yet? This way you could use mjml in your mail templates like this:

<script>
  let greeting = 'Hello World';
</script>

<template lang="mjml">
  <mjml>
    <mj-body>
      <mj-section>
        <mj-column>
          <mj-text>
            {greeting}
          </mj-text>
        </mj-column>
      </mj-section>
    </mj-body>
  </mjml>
</template>

Untested, I just copied over the example from mjml's readme.

If you'd implement such a preprocessor, I'd be happy to test it with svelte-mail 😀

Anyway, mjml already does a lot of the transformations I do, e.g. the inlining of styles. Does it even make sense to use both tools / what's you use case?

bjufre commented 3 years ago

@LukasHechenberger how would we pass the preprocessor option to the renderMail function? Or is it taken care of automatically for us if we have a svelte.config.js somehow?

Asking because I'm running into a similar situation where we have the mailers written already in mjml and we're moving to Sveltekit and we would like to know how we can do this. We have a rough idea/draft for the processor which is really simple but should work.

LukasHechenberger commented 3 years ago

You pass compiled components to this package, so you can preprocess them as usual e.g. using the svelte rollup plugin.

rohanrajpal commented 1 year ago

I guess this blog might be of help here https://escape.tech/blog/sveltemails/