Skip to content

A golang wrapper around mrml the rust implementation of mjml

License

Notifications You must be signed in to change notification settings

codedninja/mrmlgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MRML Go

Go Reference GitHub License

A Go wrapper for MRML, the MJML markup language implemented in rust.

Installation

go get github.com/codedninja/mrmlgo

Usage

package main

import (
	"fmt"
	"github.com/codedninja/mrmlgo"
)

func main() {
    mjml := `
    <mjml>
        <mj-body>
        <mj-section>
        <mj-column>
            <mj-image width="100px" src="/assets/img/logo-small.png"></mj-image>

            <mj-divider border-color="#F45E43"></mj-divider>

            <mj-text font-size="20px" color="#F45E43" font-family="helvetica">Hello World</mj-text>
        </mj-column>
        </mj-section>
    </mj-body>
    </mjml>`


    options, _ := mrmlgo.NewParseOptions(map[string]string{})
    parsed, _ := mrmlgo.ParseMJML(mjml)

    html, _ := parsed.ToHTML();
    
    fmt.Println(html)
}

Detailed Usage

At the this current moment mrmlgo only supports in memory includes. You can pass a map[string]string when creating calling NewParseOptions. The format is ``map[filename]contents`.

package main

import (
	"fmt"
	"github.com/codedninja/mrmlgo"
)

func main() {
	includes := map[string]string{
		"hello-world.mjml": "<mj-text>Hello World</mj-text>",
	}

    mjml := `
    <mjml>
        <mj-body>
            <mj-include path="hello-world.mjml" />
        </mj-body>
    </mjml>`

	options, _ := mrmlgo.NewParseOptions(includes)
    parsed, _ := options.ParseMJML(mjml); 
    output, _ := parsed.ToHTML();

	fmt.Println("Output:", output)
}

Contributing

Coming soon.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • mrml - MJML Crate
  • mjml - The only framework that makes responsive emails easy.

Support

If you encounter any issues or have questions, please open an issue.

TODO

  • Github workflow for building rust libraries
  • Add tests

About

A golang wrapper around mrml the rust implementation of mjml

Resources

License

Stars

Watchers

Forks

Packages

No packages published