Class IncludeProcessor

java.lang.Object
dev.jcputney.mjml.parser.IncludeProcessor

public final class IncludeProcessor extends Object
Processes mj-include elements in the parsed MJML tree.

Supports four include types:

  • mjml (default): Includes an MJML fragment. The included content's children replace the mj-include element.
  • html: Includes raw HTML as an mj-raw element.
  • css: Includes CSS as an mj-style element (optionally inline when css-inline="inline" attribute is present).
  • css-inline: Shorthand for type="css" css-inline="inline". Includes CSS as an mj-style element with inline="inline".

Cycle detection prevents infinite recursion from circular includes.

  • Constructor Details

    • IncludeProcessor

      public IncludeProcessor(IncludeResolver resolver)
      Creates a processor with default limits for include depth and nesting depth.
      Parameters:
      resolver - the resolver to use for loading include content
    • IncludeProcessor

      public IncludeProcessor(IncludeResolver resolver, int maxInputSize)
      Creates a processor with a size limit for included content.
      Parameters:
      resolver - the resolver to use for loading include content
      maxInputSize - maximum allowed size in characters for resolved content (0 = no limit)
    • IncludeProcessor

      public IncludeProcessor(IncludeResolver resolver, int maxInputSize, int maxIncludeDepth)
      Creates a processor with limits for included content and include depth.
      Parameters:
      resolver - the resolver to use for loading include content
      maxInputSize - maximum allowed size in characters for resolved content (0 = no limit)
      maxIncludeDepth - maximum nested include depth before rejecting
    • IncludeProcessor

      public IncludeProcessor(IncludeResolver resolver, int maxInputSize, int maxIncludeDepth, int maxNestingDepth)
      Creates a processor with all limits specified.
      Parameters:
      resolver - the resolver to use for loading include content
      maxInputSize - maximum allowed size in characters for resolved content (0 = no limit)
      maxIncludeDepth - maximum nested include depth before rejecting
      maxNestingDepth - maximum element nesting depth for parsing included content
  • Method Details

    • process

      public void process(MjmlDocument document)
      Processes all mj-include elements in the document tree, recursively resolving included content and replacing mj-include nodes with the resolved content.
      Parameters:
      document - the parsed MJML document to process