mjmlio / mjml

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

Issue with mj-html-attributes and templating language tags <% %> #2744

Open cantoniriccardo opened 1 year ago

cantoniriccardo commented 1 year ago

Describe the bug When we use mj-html-attributes and a templating language like EJS inside a compontent, a tag <%= my_variable %> is not preserved as is, but it is rendered as <%= my_variable="" %="" />.

To Reproduce Steps to reproduce the behavior:

  1. Copy and paste the following code in the try-it-live tool:
    <mjml>
    <mj-head>
    <mj-html-attributes>
      <mj-selector path=".custom div">
        <mj-html-attribute name="data-id">42</mj-html-attribute>
      </mj-selector>
    </mj-html-attributes>
    </mj-head>
    <mj-body>
    <mj-section>
      <mj-column>
        <mj-text css-class="custom">
          Hello <%= world %>
        </mj-text>
      </mj-column>
    </mj-section>
    </mj-body>
    </mjml>
  2. See error

Expected behavior We expect the tag <% ... %> to be rendered as is.

MJML environment

iRyusa commented 1 year ago

Yup, I think this should be mentioned in the doc as it's not something we can fix. When Cheerio parse the document, any "look alike" xml/html will be treated as a xml tag so it will alter the output HTML