Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mjml-core

Package Overview
Dependencies
Maintainers
4
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mjml-core

mjml-core

  • 3.3.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
689K
increased by9.62%
Maintainers
4
Weekly downloads
 
Created

What is mjml-core?

The mjml-core package is a framework for creating responsive email templates using a markup language called MJML (Mailjet Markup Language). It simplifies the process of designing and coding responsive emails by providing a set of high-level components that abstract away the complexities of HTML and CSS.

What are mjml-core's main functionalities?

Basic MJML to HTML Conversion

This feature allows you to convert MJML markup into responsive HTML. The code sample demonstrates how to use the `mjml2html` function to convert a simple MJML template into HTML.

const mjml2html = require('mjml');

const mjml = `
<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text>Hello World</mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>`;

const { html, errors } = mjml2html(mjml);
console.log(html);

Custom Components

This feature allows you to create custom MJML components. The code sample demonstrates how to create and register a custom button component.

const { registerComponent, BodyComponent } = require('mjml-core');

class CustomButton extends BodyComponent {
  render() {
    return this.renderMJML(`
      <mj-button background-color="${this.getAttribute('background-color')}" href="${this.getAttribute('href')}">
        ${this.getContent()}
      </mj-button>
    `);
  }
}

registerComponent(CustomButton);

Validation

This feature provides validation for MJML templates. The code sample demonstrates how to use the `mjml2html` function with strict validation to catch any errors in the MJML markup.

const mjml2html = require('mjml');

const mjml = `
<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text>Hello World</mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>`;

const { html, errors } = mjml2html(mjml, { validationLevel: 'strict' });

if (errors.length > 0) {
  console.error('Validation errors:', errors);
} else {
  console.log(html);
}

Other packages similar to mjml-core

FAQs

Package last updated on 25 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc