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

UnexpectedToken with HTML comments in mj-head #373

Closed
eisterman opened this issue Feb 20, 2024 · 1 comment · Fixed by #374
Closed

UnexpectedToken with HTML comments in mj-head #373

eisterman opened this issue Feb 20, 2024 · 1 comment · Fixed by #374

Comments

@eisterman
Copy link

eisterman commented Feb 20, 2024

In my project I was using MRML to parse a complex mjml template, but I obtained every time the error

     Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/mjml_test`
thread 'main' panicked at src/main.rs:10:38:
parse template: UnexpectedToken(Span { start: 25, end: 45 })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After some trial and error I found out that when I have a HTML comment like <!-- things --> anywhere inside the <mj-head> block the parser fails with UnexpectedToken targeted exactly at the comment.

The example template I used to have the previous error:

<mjml>
  <mj-head>
      <!-- TODO things -->
    <mj-preview>
    </mj-preview>
  </mj-head>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-image width="100px" src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"></mj-image>
        <mj-divider border-color="#F45E43"></mj-divider>
        <mj-text font-size="20px" color="#F45E43" font-family="helvetica">Hello Test World</mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

The parser crashes even if the comment is inside <mj-preview> but not if it's inside <mj-body>

Edit: I'm using MJML version 2.1.1 but I've found the problem is present on the last version 3.0.1 too

@quentindemetz
Copy link

Hi there, I'm getting a similar error with comments inside a mj-attributes block 😉

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

Successfully merging a pull request may close this issue.

2 participants