How to use mjml-migrate - 4 common examples

To help you get started, we’ve selected a few mjml-migrate 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 mjmlio / mjml / packages / mjml-cli / src / client.js View on Github external
inputs.forEach(i => {
    try {
      let compiled
      switch (inputOpt) {
        case 'm': // eslint-disable-line no-case-declarations
          compiled = { html: migrate(i.mjml, { beautify: true }) }
          break
        case 'v': // eslint-disable-line no-case-declarations
          const mjmlJson = MJMLParser(i.mjml, { components })
          compiled = {
            errors: validate(mjmlJson, { components, initializeType }),
          }
          break
        default:
          compiled = mjml2html(i.mjml, { ...config, filePath: filePath || i.file })
      }

      convertedStream.push({ ...i, compiled })
    } catch (e) {
      EXIT_CODE = 2
      failedStream.push({ file: i.file, error: e })
    }
github mjmlio / mjml / packages / mjml-core / src / index.js View on Github external
mjmlConfigPath = null,
    noMigrateWarn = false,
  } = options

  // if mjmlConfigPath is specified then we need to handle it on each call
  if (mjmlConfigPath) handleMjmlConfig(mjmlConfigPath, registerComponent)

  if (typeof mjml === 'string') {
    mjml = MJMLParser(mjml, {
      keepComments,
      components,
      filePath,
    })
  }

  mjml = handleMjml3(mjml, { noMigrateWarn })

  const globalDatas = {
    backgroundColor: '',
    breakpoint: '480px',
    classes: {},
    classesDefault: {},
    defaultAttributes: {},
    fonts,
    inlineStyle: [],
    headStyle: {},
    componentsHeadStyle: [],
    headRaw: [],
    mediaQueries: {},
    preview: '',
    style: [],
    title: '',
github attilabuti / vscode-mjml / src / migrate.ts View on Github external
private migrate(): void {
        const activeTextEditor: TextEditor | undefined = window.activeTextEditor;
        if (!activeTextEditor) {
            return;
        }

        if (!isMJMLFile(activeTextEditor.document)) {
            window.showWarningMessage("This is not a MJML document!");

            return;
        }

        try {
            const mjml: string = migrate(activeTextEditor.document.getText());
            if (!mjml) {
                return;
            }

            const inputFileName: string = basename(getPath());
            const fileName: string = inputFileName.replace(/\.[^\.]+$/, "");
            const file: string = resolvePath(getPath(), `../${fileName}_v4.mjml`);

            const content: string | undefined = beautifyHTML(mjml);

            if (content) {
                writeFile(file, content, (error: NodeJS.ErrnoException) => {
                    if (error) {
                        window.showErrorMessage(error.message);
                    } else {
                        window.showInformationMessage(
github mjmlio / mjml-app / src / helpers / mjml.js View on Github external
export function migrateToMJML4(content) {
  return migrate(content)
}

mjml-migrate

A tool to migrate a template from MJML 3 to MJML 4

MIT
Latest version published 2 months ago

Package Health Score

89 / 100
Full package analysis

Popular mjml-migrate functions

Similar packages