Skip to content

bug: mj-raw cannot be used inside mj-list #12

Description

@hitautodestruct

MJML Bullet List version

1.2.2

MJML version

4.13.0

What operating system are you using?

Mac

Node version

19.7.0

npm or yarn version

7.18.0 (pnpm)

Current behavior

When placing a <mj-raw> tag under <mj-list> the mjml parser throws the following error:

Line 3 of undefined, included at line 143 of file /test.mjml (mj-raw) — mj-raw cannot be used inside mj-list, only inside: mj-column, mjml, mj-accordion, mj-accordion-element, mj-attributes, mj-body, mj-group, mj-head, mj-hero, mj-navbar, mj-section, mj-social, mj-wrapper

The <mj-raw> tag is necessary as we are implementing jinja2 templating syntax which dissapears after rendering the mjml to html.

Example:

<mj-raw>{% if filters|length > 0 %}</mj-raw> <!-- This works fine -->
<mj-list>
  {% for key, value in filters.items() %}              <!-- This does not render in html and therefore requires an mj-raw -->
  <mj-li bullet-color="#8aabff" color="#2a2a2a" padding-left="7px">
    {{ key }}
  </mj-li>
  {% endfor %}
</mj-list>

Notice the missing {% for key, value in filters.items() %} in the rendered output

<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
  <tbody> {% if filters|length > 0 %} <tr>
      <td vertical-align="top" style="font-size:0px;padding-left:25px;word-break:break-word;">
        <div class="mj-column-px-NaN mj-outlook-group-fix list" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
          <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
            <tbody>
              <tr>
                <td style="vertical-align:top;padding-left:25px;">
                  <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="" width="100%">
                    <tbody>
                      <tr>
                        <td vertical-align="top" style="font-size:0px;padding-left:7px;word-break:break-word;">
                          <ul role="presentation" class="list-item-wrap" align="left" type="disc" style="color:#2a2a2a;font-family:Open Sans, Helvetica, Arial, sans-serif;font-size:13px;mso-line-height-rule:exactly;margin-top:0;margin-left:7px;margin-bottom:0;padding:0;">
                            <li role="list-item" class="list-item" style="color:#8aabff;margin:0;padding:0;padding-left:3px;">
                              <span class="list-item__text" style="color:#2a2a2a;text-align:left;">
                                {{ key }}
                              </span>
                            </li>
                          </ul>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </td>
    </tr>
  </tbody>
</table>

Expected behavior

<mj-list> should be able to include an <mj-raw> tag and render the markup unprocessed.

Steps to reproduce

Include an <mj-raw> tag inside of an <mj-list> tag.

Relevant log output

No response

Related code

No response

Preferred solution

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugProblems in the program which will cause issues for users or implementors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions