npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

browser-mjml

v4.6.7

Published

MJML: the only framework that makes responsive-email easy

Downloads

29

Readme

MJML 4


Introduction

MJML is a markup language created by Mailjet and designed to reduce the pain of coding a responsive email. Its semantic syntax makes it easy and straightforward while its rich standard components library fastens your development time and lightens your email codebase. MJML’s open-source engine takes care of translating the MJML you wrote into responsive HTML.

Installation

You can install MJML with NPM to use it with NodeJS or the Command Line Interface. If you're not sure what those are, head over to Usage for other ways to use MJML.

npm install mjml

Usage

Online

Don't want to install anything? Use the free online editor!

Applications and plugins

MJML comes with an ecosystem of tools and plugins, check out:

For more tools, check the Community page.

Command line interface

Compiles the file and outputs the HTML generated in output.html

mjml input.mjml -o output.html

You can pass optional arguments to the CLI and combine them.

argument | description | default value ---------|--------|-------------- mjml -m [input] | Migrates a v3 MJML file to the v4 syntax | NA mjml [input] -o [output] | Writes the output to [output] | NA mjml [input] -s | Writes the output to stdout | NA mjml -w [input] | Watches the changes made to [input] (file or folder) | NA mjml [input] --config.beautify | Beautifies the output (true or false) | true mjml [input] --config.minify | Minifies the output (true or false) | false

See mjml-cli documentation for more information about config options.

Inside Node.js

import mjml2html from 'mjml'

/*
  Compile an mjml string
*/
const htmlOutput = mjml2html(`
  <mjml>
    <mj-body>
      <mj-section>
        <mj-column>
          <mj-text>
            Hello World!
          </mj-text>
        </mj-column>
      </mj-section>
    </mj-body>
  </mjml>
`, options)


/*
  Print the responsive HTML generated and MJML errors if any
*/
console.log(htmlOutput)

You can pass optional options as an object to the mjml2html function:

option | unit | description | default value -------------|--------|--------------|--------------- fonts | object | Default fonts imported in the HTML rendered by HTML | See in index.js keepComments | boolean | Option to keep comments in the HTML output | true beautify | boolean | Option to beautify the HTML output | false minify | boolean | Option to minify the HTML output | false validationLevel | string | Available values for the validator: 'strict', 'soft', 'skip' | 'soft' filePath | string | Path of file, used for relative paths in mj-includes | '.' preprocessors | array of functions | Preprocessors applied to the xml before parsing. Input must be xml, not json. Functions must be (xml: string) => string | [] juicePreserveTags | Preserve some tags when inlining css, see mjml-cli documentation for more info | NA minifyOptions | Options for html minifier, see mjml-cli documentation for more info | NA mjmlConfigPath | string | The path or directory of the .mjmlconfig file (for custom components use) | process.cwd() useMjmlConfigOptions | Allows to use the config attribute from .mjmlconfig file | false

API

A free-to-use MJML API is available to make it easy to integrate MJML in your application. Head over here to learn more about the API.

MJML Slack

MJML wouldn't be as cool without its amazing community. Head over the Community Slack to meet fellow MJML'ers.