How to use mjml-parser-xml - 4 common examples

To help you get started, we’ve selected a few mjml-parser-xml 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-core / src / index.js View on Github external
minify = false,
    minifyOptions = {},
    juiceOptions = {},
    juicePreserveTags = null,
    skeleton = defaultSkeleton,
    validationLevel = 'soft',
    filePath = '.',
    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: [],
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-migrate / src / migrate.js View on Github external
export default function migrate(input, options = {}) {
  const { beautify } = options
  if (typeof input === 'object') return loopThrough(input)

  const mjmlJson = MJMLParser(input, { components, ignoreIncludes: true })
  loopThrough(mjmlJson)

  return beautify
    ? htmlBeautify(jsonToXML(mjmlJson), beautifyOptions)
    : jsonToXML(mjmlJson)
}
github mjmlio / mjml / packages / mjml-core / src / createComponent.js View on Github external
renderMJML(mjml, options = {}) {
    if (typeof mjml === 'string') {
      mjml = MJMLParser(mjml, {
        ...options,
        components,
        ignoreIncludes: true,
      })
    }

    return this.context.processing(mjml, this.context)
  }
}

mjml-parser-xml

mjml-parser-xml

MIT
Latest version published 11 months ago

Package Health Score

91 / 100
Full package analysis

Popular mjml-parser-xml functions

Similar packages