How to use the mjml.MJMLValidator function in mjml

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 mjmlio / atom-linter-mjml / index.js View on Github external
const filePath = TextEditor.getPath();
          const fileText = TextEditor.getText()

          try {
            MJMLDocument = documentParser(fileText)
          } catch (e) {
            reject(e)
          }

          const body = getMJBody(MJMLDocument)

          if (!body || !body.children || body.children.length == 0) {
            reject()
          }

          const report = MJMLValidator(body.children[0])
          const formattedError = report.map(e => {
            const line = e.line - 1
            const currentLine = TextEditor.getBuffer().lineForRow(e.line - 1)

            return {
              filePath,
              range: [[line, currentLine.indexOf('<')], [line, TextEditor.getBuffer().lineLengthForRow(line)]],
              type: 'Error',
              text: e.message
            }
          })
          resolve(formattedError)
        })
      }

mjml

MJML: the only framework that makes responsive-email easy

MIT
Latest version published 6 months ago

Package Health Score

87 / 100
Full package analysis