How to use mjml - 10 common examples

To help you get started, we’ve selected a few mjml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github justinsisley / mjml-utils / src / builder / index.js View on Github external
builder.build = (filePath, outputDir, extension) => {
  // No-op if filePath is not a file
  if (!fs.statSync(filePath).isFile()) {
    return;
  }

  const filename = getTemplateFilename(filePath).replace('.mjml', extension);

  try {
    const outputPath = path.join(process.cwd(), outputDir);
    mkdir(outputPath);

    const startTime = Date.now();
    const data = fs.readFileSync(`${filePath}`, 'utf8');
    const rendered = mjml2html(data);

    fs.writeFileSync(`${outputPath}/${filename}`, rendered.html);

    const endTime = Date.now();
    const totalTime = endTime - startTime;
    console.log(`Rendered ${filename} in ${totalTime}ms`); // eslint-disable-line
  } catch (error) {
    console.error(`Unable to render ${filename}`);
    console.error(error.message);
  }
};
github contentjet / contentjet-api / dist / viewsets / ProjectInviteViewSet.js View on Github external
const fs = require("fs");
const path = require("path");
const url = require("url");
const ejs = require("ejs");
const { mjml2html } = require('mjml'); // tslint:disable-line
const config_1 = require("../config");
const lodash_1 = require("lodash");
const BaseViewSet_1 = require("./BaseViewSet");
const ProjectInvite_1 = require("../models/ProjectInvite");
const ValidationError_1 = require("../errors/ValidationError");
const middleware_1 = require("../authentication/jwt/middleware");
const middleware_2 = require("../authorization/middleware");
const objection_1 = require("objection");
const validate_1 = require("../utils/validate");
const sendMail = config_1.default.MAIL_BACKEND.sendMail;
const projectInviteHTML = mjml2html(fs.readFileSync(path.resolve(__dirname, '../../templates/mail/project-invite.mjml'), 'utf8')).html;
const projectInviteTXT = fs.readFileSync(path.resolve(__dirname, '../../templates/mail/project-invite.txt'), 'utf8');
const createConstraints = {
    name: {
        presence: true,
        length: {
            maximum: 128
        }
    },
    email: {
        presence: true,
        email: true
    }
};
const acceptConstraints = {
    token: {
        presence: true
github contentjet / contentjet-api / src / viewsets / UserViewSet.ts View on Github external
import url = require('url');
import * as ejs from 'ejs';
import { cloneDeep } from 'lodash';
const { mjml2html } = require('mjml'); // tslint:disable-line
import { transaction } from 'objection';
import User from '../models/User';
import Project from '../models/Project';
import ProjectInvite, { IInvitePayload } from '../models/ProjectInvite';
import BaseViewSet from './BaseViewSet';
import ValidationError from '../errors/ValidationError';
import NotFoundError from '../errors/NotFoundError';
import config from '../config';
import { requireAuthentication } from '../authentication/jwt/middleware';
import validate from '../utils/validate';

const signUpHTML = mjml2html(
  fs.readFileSync(
    path.resolve(__dirname, '../../templates/mail/sign-up-verify.mjml'), 'utf8'
  )
).html;
const signUpTXT = fs.readFileSync(
  path.resolve(__dirname, '../../templates/mail/sign-up-verify.txt'), 'utf8'
);
const requestPasswordResetHTML = mjml2html(
  fs.readFileSync(
    path.resolve(__dirname, '../../templates/mail/request-password-reset.mjml'), 'utf8'
  )
).html;
const requestPasswordResetTXT = fs.readFileSync(
  path.resolve(__dirname, '../../templates/mail/request-password-reset.txt'), 'utf8'
);
github FlowzPlatform / workflow / JobQue / twitter / approval_worker.js View on Github external
.then(function (response) {
        emailTemplateHtml = response.data
        processLog = _.chain(processLog).orderBy(['lastModified'], ['asc']).findLast((f) => { return f.jobId === job.data.jobId }).value()
        for (var i = 0; i < runningProcess.inputProperty[0].entityschema.entity.length; i++) {
          let element = runningProcess.inputProperty[0].entityschema.entity[i].name
            // element = element.toLowerCase()
          let index = emailTemplateHtml.search('"' + element + '"')
            // element = _.capitalize(element)
          emailTemplateHtml = emailTemplateHtml.substr(0, index + element.length + 3) + processLog.input[0][element] + emailTemplateHtml.substr(index + element.length + 3)
        }
        emailTemplateHtml = mjml2html(emailTemplateHtml)
      })
      .catch(function (error) {
github contentjet / contentjet-api / src / viewsets / ProjectInviteViewSet.ts View on Github external
import fs = require('fs');
import path = require('path');
import url = require('url');
import * as ejs from 'ejs';
const { mjml2html } = require('mjml'); // tslint:disable-line
import config from '../config';
import { cloneDeep } from 'lodash';
import BaseViewSet from './BaseViewSet';
import ProjectInvite from '../models/ProjectInvite';
import ValidationError from '../errors/ValidationError';
import { requireAuthentication } from '../authentication/jwt/middleware';
import { requirePermission } from '../authorization/middleware';
import { transaction } from 'objection';
import validate from '../utils/validate';

const projectInviteHTML = mjml2html(
  fs.readFileSync(
    path.resolve(__dirname, '../../templates/mail/project-invite.mjml'), 'utf8'
  )
).html;
const projectInviteTXT = fs.readFileSync(
  path.resolve(__dirname, '../../templates/mail/project-invite.txt'), 'utf8'
);

const createConstraints = {
  name: {
    presence: true,
    length: {
      maximum: 128
    }
  },
  email: {
github Lambda-School-Labs / CS10-restaurant-pos / api / controllers / employees / employeeRegister.js View on Github external
.then(employeeInfo => {
      // Send the employees pin number
      const confirmationEmail = {
        to: email,
        from: 'support@maincourse.app',
        subject: 'Welcome to Main Course!',
        text: 'Thank you for signing up for Main Course',
        html: mjml2html(`
      
      
    
  
    

      

        Main Course POS

      

    
    

      
github Lambda-School-Labs / CS10-restaurant-pos / api / controllers / employees / adminRegister.js View on Github external
.then(adminInfo => {
      // Send a confirmation email
      if (process.env.NODE_ENV !== 'test') {
        const confirmationEmail = {
          to: email,
          from: 'support@maincourse.app',
          subject: 'Welcome to Main Course!',
          text: 'Thank you for signing up for Main Course',
          html: mjml2html(`
        
        
      
    
      

        

        Main Course POS

        

      
      

        
github epayet / mjml-starter-kit / components / Title.js View on Github external
// TODO temporary fix, remove when mjml is updated
    return (
      
        {content}
      
    )
  }
}

Title.tagName = tagName
Title.defaultMJMLDefinition = defaultMJMLDefinition
Title.endingTag = endingTag
Title.columnElement = columnElement

registerMJElement(Title)
export default Title
github image-charts / mjml-chart / test / mjml-chart.spec.js View on Github external
it('should render a mjml chart', () => {
      expect(
        mjml2html(`
          
            
              
            
          `).html
      ).to.contain(
        ''
      );
    });
github mjmlio / mjml / test / assets / generatedComponentEndingTag.js View on Github external
import { MJMLColumnElement, elements, registerElement } from 'mjml'
import merge from 'lodash/merge'
import React, { Component } from 'react'

/*
 * Wrap your dependencies here.
 */
const { text: MjText } = elements

const NAME = 'mock'

@MJMLColumnElement({
  tagName: 'mj-mock',
  content: ' ',

  /*
   * These are your default css attributes
   */
  attributes: {
    'color': '#424242',
    'font-family': 'Helvetica',
    'margin-top': '10px'
  }
})
class Mock extends Component {

  /*
   * Build your styling here

mjml

MJML: the only framework that makes responsive-email easy

MIT
Latest version published 24 days ago

Package Health Score

89 / 100
Full package analysis