Code Monkey home page Code Monkey logo

mjml-go's People

Contributors

codefromthecrypt avatar f21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mjml-go's Issues

I am getting an error hard to debug

Hi, first and foremost, thank you for working on this.

Here is the situation:
I am running mjml-go inside an app, I read an .mjml file and then call mjml.toHTML(fileContent). When I run the app locally everything works fine, I also wrote some tests around the mjml functionality in my app, and when tests run, everything works fine (ie mjml compiles to HTML).

Now, I deployed my app in an EKS cluster and the app is running fine, but when the time comes to compile mjml I am getting the following error:
error: input is missing mjml property

that error seems to come from the JS compile function here
and that gets called from the go binding here

I wonder why would the property seem to be missing on my live app whereas in other instances it compiles just fine (and I also made a small toy app to test it out and of course that is working too!)

I guess my issue here is I can't be sure what that json payload looks like on the JS side, and perhaps would be nice to have some way of telling what is happening with the payload that it lacks the proper content for some reason!

any tips/pointers on how to approach this issue?

Error "Attribute mj-repeat is illegal"

I'm using mjml 0.14.6 in a project to compile an mjml file to html. I'm hitting an error when using "mj-repeat".

{"error":"MJML compilation error:\n- Line 114 of (mj-text) - Attribute mj-repeat is illegal","level":"error","msg":"Failed to generate html email body","time":"2024-04-03T23:24:19Z"}

Is this a known issue, or something that might be a config issue on my end?

Update of mjml version

Could you update the mjml version to the newest one? current: 4.12.0, newest: 4.14.1
Thank you!

Need a new release

Hi,

Latest release v0.7.0 fails with(go get -u):

...        github.com/Boostport/mjml-go imports
        github.com/tetratelabs/wazero/wasi_snapshot_preview1: cannot find module providing package github.com/tetratelabs/wazero/wasi_snapshot_preview1

A new release is needed.

For temporary solution:

 go get github.com/Boostport/mjml-go@cef2972

Thanks

New version(v1.0.0-pre.8) of wazero breaks

New version(v1.0.0-pre.8) of wazero breaks this lib

../../../../go/pkg/mod/github.com/!boostport/[email protected]/mjml.go:288:20: too many arguments in call to r.NewHostModuleBuilder("env").NewFunctionBuilder().WithFunc(returnResult).WithParameterNames("ptr", "len", "ident").Export("return_result").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32) uint32 {…}).Export("get_static_file").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32, _ uint32, _ uint32, _ uint32) uint32 {…}).Export("request_set_field").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32, _ uint32, _ uint32) {…}).Export("resp_set_header").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32) uint32 {…}).Export("cache_get").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32, _ uint32, _ uint32) uint32 {…}).Export("add_ffi_var").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32) uint32 {…}).Export("get_ffi_result").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32, _ uint32) {…}).Export("return_error").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32, _ uint32, _ uint32, _ uint32) uint32 {…}).Export("fetch_url").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32, _ uint32, _ uint32) uint32 {…}).Export("graphql_query").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32, _ uint32) uint32 {…}).Export("db_exec").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32, _ uint32, _ uint32, _ uint32) uint32 {…}).Export("cache_set").NewFunctionBuilder().WithFunc(func(_ uint32, _ uint32, _ uint32, _ uint32) uint32 {…}).Export("request_get_field").NewFunctionBuilder().WithFunc(func(ctx context.Context, m api.Module, ptr uint32, size uint32, level uint32, ident uint32) {…}).Export("log_msg").Instantiate
        have (context.Context, wazero.Runtime)
        want (context.Context)

How to escape template control structures in MJML to allow them to pass through to html?

I'm using mjml-go to process an mjml file into HTML and then html/template to do variable replacement.
In the mjml file, I'd like to be able to use control structures like if and range.

When I pass an mjml file that contains the code below into a call like:

htmlData, err = mjml.ToHTML(context.Background(), string(data), mjml.WithMinify(true))

The HTML does not contain the if and range templates, but it does contain the {{.NoteAnything}} variable replacements.

Is there a way to allow these structures to pass through?

    {{if .PreviousNotes}}
      {{range .PreviousNotes}}
        <mj-section background-color="#ffffff" padding="12px 0">
          <mj-column>
            <mj-table border="1px solid #bbbbbb" padding="0 24px" font-family="Inter">
              <tr style="border-bottom: 1px solid #bbbbbb;">
                <td style="padding: 8px 12px; font-size: 12px;"><span style="font-weight: 600">{{.NoteUserName}}</span>: {{.NoteUserTitle}} - {{.TicketClientName}}</td>
                <td style="padding: 8px 12px; text-align: right; font-size: 12px; font-weight: 600;">{{.NoteCreatedAt}}</td>
              </tr>
              <tr>
                <td colspan="2" style="padding: 8px 12px">
                  {{.NoteBody}}
                </td>
              </tr>
              <tr>
                <td colspan="2" style="padding: 8px 12px; font-size: 12px;">
                  <span style="font-weight: 600">Visibility:</span> {{.NoteVisibility}}
                </td>
              </tr>
            </mj-table>
          </mj-column>
        </mj-section>
      {{end}}
    {{end}}
    ```

[ERROR] Secure random number generation...

I want to format the following template but I get this error in the jsonResult (res) object at the time of making the json.Unmarshal (mjml.go line 204)

Template:
<mjml> <mj-body background-color="#fff"> <mj-section background-color="#ef6451"> <mj-column> <mj-navbar base-url="https://link.com" hamburger="hamburger" ico-color="#ffffff"> <mj-navbar-link href="#" color="#ffffff">Nav1</mj-navbar-link> <mj-navbar-link href="#" color="#ffffff">Nav2</mj-navbar-link> <mj-navbar-link href="#" color="#ffffff">Nav3</mj-navbar-link> <mj-navbar-link href="#" color="#ffffff">Nav4</mj-navbar-link> <mj-navbar-link href="#" color="#ffffff">Nav5</mj-navbar-link> </mj-navbar> </mj-column> </mj-section> <mj-section full-width="full-width"> <mj-column> <mj-text align="center" font-size="20px"> {{ title }} </mj-text> </mj-column> </mj-section> <mj-section> <mj-column> <mj-button font-family="Helvetica" background-color="#f45e43" color="white"> Button 1 </mj-button> </mj-column> <mj-column> <mj-button font-family="Helvetica" background-color="#f45e43" color="white"> Button 2 </mj-button> </mj-column> <mj-column> <mj-button font-family="Helvetica" background-color="#f45e43" color="white"> Button 3 </mj-button> </mj-column> </mj-section> </mj-body> </mjml>

Err: Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11

Im using a IDE to test it and go 1.18.2.
I execute the method with these options:
mjml.ToHTML(context.Background(), stringTemplate, mjml.WithFonts(mjml.Fonts{}), mjml.WithBeautify(true), mjml.WithMinify(true), mjml.WithValidationLevel("skip"))

After several tests I know that the error comes from the section that includes the navbar, it only happens when the navbar is added.

Template in online editor

Any recommendations? Is this a limitation of the package?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.