Skip to content

Commit

Permalink
Automatic component dependencies registration (#2793)
Browse files Browse the repository at this point in the history
* Automatic component dependencies registration
  • Loading branch information
Freezystem authored Jan 29, 2024
1 parent 170db3f commit af19dde
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/mjml-core/src/components.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { kebabCase } from 'lodash'
import { registerDependencies } from 'mjml-validator'

const components = {}

Expand All @@ -8,8 +9,12 @@ export function assignComponents(target, source) {
}
}

export function registerComponent(Component) {
export function registerComponent(Component, options = {}) {
assignComponents(components, [Component])

if (Component.dependencies && options.registerDependencies) {
registerDependencies(Component.dependencies)
}
}

export default components

0 comments on commit af19dde

Please sign in to comment.