Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mj-attributes with mj-body leads to empty body #51

Open
mrcoles opened this issue Jan 30, 2024 · 2 comments
Open

mj-attributes with mj-body leads to empty body #51

mrcoles opened this issue Jan 30, 2024 · 2 comments

Comments

@mrcoles
Copy link

mrcoles commented Jan 30, 2024

With mjml==0.10.0 I get the following unexpected results when passing in an mj-body tag inside mj-attributes within mj-head. Also, if I try this on the MJML test page the body properly gets a background color.

Call with mj-body

mjml_to_html('''<mjml>
  <mj-head>
    <mj-attributes>
      <mj-body background-color="#F6F6F6" />
    </mj-attributes>
  </mj-head>
  <mj-body>
    <mj-text>
      TESTTESTTESTTESTTESTTESTTEST
    </mj-text>
  </mj-body>
</mjml>''')

Result has no content inside body:

{"html": "<!doctype html>\n<html xmlns="http://www.w3.org/1999/xhtml\" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">\n \n <title>\n \n </title>\n \n <meta http-equiv="X-UA-Compatible" content="IE=edge">\n \n <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1">\n <style type="text/css">\n #outlook a { padding:0; }\n body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; }\n table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; }\n img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; }\n p { display:block;margin:13px 0; }\n </style>\n \n \n \n \n <style type="text/css">\n\n \n \n </style>\n <style type="text/css"></style>\n \n \n <body style="word-spacing:normal;">\n \n <div style="">\n \n", "errors": []}

Call with mj-html instead

I’m not sure mj-html is even supported in mjml, but you can also just remove it entirely and get the same result below:

mjml_to_html('''<mjml>
  <mj-head>
    <mj-attributes>
      <mj-html background-color="#F6F6F6" />
    </mj-attributes>
  </mj-head>
  <mj-body>
    <mj-text>
      TESTTESTTESTTESTTESTTESTTEST
    </mj-text>
  </mj-body>
</mjml>''')

Result has expected TESTTEST… content inside body:

{"html": "<!doctype html>\n<html xmlns="http://www.w3.org/1999/xhtml\" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">\n \n <title>\n \n </title>\n \n <meta http-equiv="X-UA-Compatible" content="IE=edge">\n \n <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1">\n <style type="text/css">\n #outlook a { padding:0; }\n body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; }\n table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; }\n img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; }\n p { display:block;margin:13px 0; }\n </style>\n \n \n \n \n <link href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700\" rel="stylesheet" type="text/css">\n <style type="text/css">\n @import url(https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700);\n </style>\n \n\n \n \n <style type="text/css">\n\n \n \n </style>\n <style type="text/css"></style>\n \n \n <body style="word-spacing:normal;">\n \n <div style=""><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000">TESTTESTTESTTESTTESTTESTTEST\n \n", "errors": []}

@FelixSchwarz
Copy link
Owner

Thank you for the detailed description. I just tried it with the online editor and that one tells me that <mj-text> cannot be used inside mj-body: https://mjml.io/try-it-live/xo_HA0Xzex

Please try wrapping the mj-text inside mj-column.

@FelixSchwarz
Copy link
Owner

Just wanted to mention that I could reproduce the issue and it seems to be very specific to mj-attributes applying to mj-body. I need to debug this a bit further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants