Class GlobalContext

java.lang.Object
dev.jcputney.mjml.context.GlobalContext

public class GlobalContext extends Object
Document-wide context gathered during head processing. Facade that delegates to three focused sub-contexts:
  • MetadataContext — title, previewText, breakpoint, containerWidth, bodyBackgroundColor, headComments, fileStartContent
  • StyleContext — fonts, fontUrlOverrides, styles, componentStyles, inlineStyles, mediaQueries, fluidOnMobileUsed, registeredStyleKeys
  • AttributeContext — defaultAttributes, classAttributes, htmlAttributes

Access sub-contexts directly via metadata(), styles(), and attributes().

Thread safety: This class is not thread-safe. Each RenderPipeline creates its own instance, so concurrent renders do not share a GlobalContext.

  • Constructor Details

    • GlobalContext

      public GlobalContext(MjmlConfiguration configuration)
      Creates a new global context with the given configuration.
      Parameters:
      configuration - the MJML configuration for this render
  • Method Details

    • metadata

      public MetadataContext metadata()
      Returns the document metadata sub-context (title, preview, breakpoint, etc.).
      Returns:
      the metadata sub-context
    • styles

      public StyleContext styles()
      Returns the style sub-context (fonts, CSS, media queries, etc.).
      Returns:
      the style sub-context
    • attributes

      public AttributeContext attributes()
      Returns the attribute cascade sub-context (defaults, classes, HTML attributes).
      Returns:
      the attribute cascade sub-context
    • getConfiguration

      public MjmlConfiguration getConfiguration()
      Returns the MJML configuration for this render.
      Returns:
      the MJML configuration