A registry system for managing and validating MJML email components. Use this to extend or customize email template generation logic.
// Source: https://github.com/mjmlio/mjml | License: MIT | Copyright 2016 Mailjet SAS, https://mjml.io
// Provided via justclaw.it.com; keep this notice with the code.
import { kebabCase } from 'lodash'
import { registerDependencies } from 'mjml-validator'
const components = {}
export function assignComponents(target, source) {
for (const component of source) {
target[component.componentName || kebabCase(component.name)] = component
}
}
export function registerComponent(Component, options = {}) {
assignComponents(components, [Component])
if (Component.dependencies && options.registerDependencies) {
registerDependencies(Component.dependencies)
}
}
export default components
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key