Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Bug]: Working with a rendered blade view as input does not work on Windows environment #13

Closed
engel-m opened this issue Jan 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@engel-m
Copy link

engel-m commented Jan 2, 2024

What happened?

Currently I have a bug where the exact same code always works when running my app on MacOS and Linux machines, but I get a NodeJS JSON parse error on Windows environments.

My code is as follows:

in the content function of a Laravel mailable, I generate MJML like this:

        $mjmlViewData = view('mails.revision2023.account.activated', [
            'header' => __('mails.account.activated.subject'),
            'exampleData' => $exampleData
        ])->render();
        
        $html = Mjml::new()->toHtml($mjmlViewData);

the mail template looks like this basically:

<mjml>
    <mj-head>
        <mj-title>Foneday</mj-title>
.... etc
</mjml>

The toHtml() function works fine and renders HTML that can be used perfectly in emails, on Mac.

But on Windows, I get the following error:

The command ""C:\Program Files\nodejs\\node.EXE" mjml.mjs "[""<mjml>\r\n <mj-head>\r\n <mj-title>Test<\/mj-title>\r\n <mj-raw>\r\n <meta name=\""color-scheme\"" content=\""light dark\"">\r\n <meta name=\""supported-color-schemes\"" content=\""light dark\"">\r\n <link rel=\""preconnect\"" href=\""https:\/\/fonts.googleapis.com\"">\r\n <link rel=\""preconnect\"" href=\""https:\/\/fonts.gstatic.com\"" crossorigin>\r\n <\/mj-raw>\r\n\r\n <mj-font name=\""Montserrat\""

.......

<\/mj-body>\r\n<\/mjml>"",{""keepComments"":true,""ignoreIncludes"":false,""beautify"":false,""minify"":false,""validationLevel"":""strict"",""filePath"":"".""}]"" failed. Exit Code: 1(General error) Working directory: C:\Projects\shop\vendor\spatie\mjml-php\bin Output: ================ Error Output: ================ undefined:1 SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at file:///C:/Projects/shop/vendor/spatie/mjml-php/bin/mjml.mjs:3:19 at ModuleJob.run (node:internal/modules/esm/module_job:198:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:385:24) at async loadESM (node:internal/process/esm_loader:88:5) at async handleMainPromise (node:internal/modules/run_main:61:12)

I tried a lot of things, like minifying, trimming characters, shortening the mjml code, etc etc., but nothing works.

The issue is also not with my node environment setup, because if I enter the code as input from the readme of the package then the toHtml() function does work and render the email correctly.:

$mjml = <<<'MJML'
    <mjml>
      <mj-body>
        <mj-section>
          <mj-column>
            <mj-text invalid-attribute>Hello World</mj-text>
          </mj-column>
        </mj-section>
      </mj-body>
    </mjml>
    MJML;

$html = Mjml::new()->toHtml($mjml);

The above works on my machine.

The issue seems to be with the rendered blade view content. But this sequence does work without issue on Mac.

What could be the problem here?

How to reproduce the bug

Try to convert pre-rendered mjml from a blade view to Html on a Windows environment.

Package Version

1.0.2

PHP Version

8.2.0

Which operating systems does with happen with?

Windows

Notes

No response

@engel-m engel-m added the bug Something isn't working label Jan 2, 2024
@spatie spatie locked and limited conversation to collaborators Jan 2, 2024
@freekmurze freekmurze converted this issue into discussion #14 Jan 2, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant