How to use the mjml-core.registerComponent function in mjml-core

To help you get started, we’ve selected a few mjml-core 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 image-charts / mjml-chart / examples / simple-chart.js View on Github external
import path from 'path'

import mjml2html from 'mjml';
import {registerComponent, components } from 'mjml-core';
import ChartComponent from '../src';

// First require mjml-chart:
// import mjmlchart from 'mjml-chart'
// ^^^ this import should be used in your project instead
import mjmlchart from '../'

// Then register mjml-chart
registerComponent(mjmlchart);


/*
  Compile an mjml string
*/
const {errors, html} = mjml2html(require('fs').readFileSync(path.resolve(__dirname, 'simple-chart.mjml'), 'utf8'))

if(errors.length > 0){
  console.error(errors);
  process.exit(1);
}
/*
  Print the responsive HTML generated
*/
console.log(html); // eslint-disable-line no-console
github image-charts / mjml-chart / test / mjml-chart.spec.js View on Github external
before(() => {
    registerComponent(ChartComponent);
  });
github mjmlio / mjml-component-boilerplate / gulpfile.babel.js View on Github external
watchedComponents.forEach(compPath => {
        const fullPath = path.join(process.cwd(), compPath.replace(/^components/, 'lib'))
        delete require.cache[fullPath]
        registerComponent(require(fullPath).default)
      })