Class ComponentRegistry

java.lang.Object
dev.jcputney.mjml.component.ComponentRegistry

public class ComponentRegistry extends Object
Registry mapping MJML tag names to component factories. Supports registration of custom components.
  • Constructor Details

    • ComponentRegistry

      public ComponentRegistry()
      Creates a new, empty component registry.
  • Method Details

    • register

      public void register(String tagName, ComponentFactory factory)
      Registers a component factory for the given tag name.
      Parameters:
      tagName - the MJML tag name to register (e.g. "mj-section")
      factory - the factory used to create component instances for the tag
      Throws:
      IllegalStateException - if the registry has been frozen
    • freeze

      public void freeze()
      Freezes this registry, preventing further registrations.
    • hasFactory

      public boolean hasFactory(String tagName)
      Returns whether a factory is registered for the given tag name.
      Parameters:
      tagName - the MJML tag name to check
      Returns:
      true if a factory is registered for the tag
    • createComponent

      public BaseComponent createComponent(MjmlNode node, GlobalContext globalContext, RenderContext renderContext)
      Creates a component instance for the given node. Returns null if no factory is registered for the tag.
      Parameters:
      node - the parsed MJML node to create a component for
      globalContext - the document-wide context gathered during head processing
      renderContext - the current rendering context (container width, position, etc.)
      Returns:
      the created component instance, or null if no factory is registered