Class MjmlConfiguration
java.lang.Object
dev.jcputney.mjml.MjmlConfiguration
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructingMjmlConfigurationinstances. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault container width in pixels, matching the MJML v4 default of 600px.static final intDefault maximum include depth.static final intDefault maximum input size in characters (approximately 1 MB for ASCII).static final intDefault maximum nesting depth. -
Method Summary
Modifier and TypeMethodDescriptionstatic MjmlConfiguration.Builderbuilder()Creates a newMjmlConfiguration.Builderfor constructing anMjmlConfiguration.static MjmlConfigurationdefaults()Returns a default configuration with all settings at their default values.booleanReturns the optional content sanitizer, ornullif none is configured.Returns the custom component factories registered viaMjmlConfiguration.Builder.registerComponent(String, ComponentFactory).Returns the custom container component factories registered viaMjmlConfiguration.Builder.registerContainerComponent(String, ContainerComponentFactory).Returns the text direction for the HTML document.Returns the include resolver used to resolvemj-includepaths, ornullif none is configured.Returns the language code for the HTML document.intMaximum allowed include nesting depth formj-include.intMaximum allowed input size in characters.intMaximum allowed nesting depth for MJML elements.inthashCode()booleanWhether to escape HTML special characters in attribute values in rendered output.Returns a builder pre-populated with this configuration's values.toString()
-
Field Details
-
DEFAULT_MAX_INPUT_SIZE
public static final int DEFAULT_MAX_INPUT_SIZEDefault maximum input size in characters (approximately 1 MB for ASCII).- See Also:
-
DEFAULT_MAX_NESTING_DEPTH
public static final int DEFAULT_MAX_NESTING_DEPTHDefault maximum nesting depth.- See Also:
-
DEFAULT_MAX_INCLUDE_DEPTH
public static final int DEFAULT_MAX_INCLUDE_DEPTHDefault maximum include depth.- See Also:
-
DEFAULT_CONTAINER_WIDTH
public static final int DEFAULT_CONTAINER_WIDTHDefault container width in pixels, matching the MJML v4 default of 600px.- See Also:
-
-
Method Details
-
builder
Creates a newMjmlConfiguration.Builderfor constructing anMjmlConfiguration.- Returns:
- a new builder instance
-
defaults
Returns a default configuration with all settings at their default values.- Returns:
- a default
MjmlConfigurationinstance
-
getLanguage
Returns the language code for the HTML document. Defaults to"und"(undetermined).- Returns:
- the language code
-
getDirection
Returns the text direction for the HTML document. Defaults toDirection.AUTO.- Returns:
- the text direction
-
getIncludeResolver
Returns the include resolver used to resolvemj-includepaths, ornullif none is configured.- Returns:
- the include resolver, or
null
-
getCustomComponents
Returns the custom component factories registered viaMjmlConfiguration.Builder.registerComponent(String, ComponentFactory).- Returns:
- an unmodifiable map of tag names to component factories
-
getCustomContainerComponents
Returns the custom container component factories registered viaMjmlConfiguration.Builder.registerContainerComponent(String, ContainerComponentFactory). Container components receive theComponentRegistryas a fourth argument, allowing them to instantiate and render child components.- Returns:
- an unmodifiable map of tag names to container component factories
-
isSanitizeOutput
public boolean isSanitizeOutput()Whether to escape HTML special characters in attribute values in rendered output. When true, characters like",<,>,&are escaped in attribute values to prevent XSS. Default is true.- Returns:
trueif output sanitization is enabled
-
getMaxInputSize
public int getMaxInputSize()Maximum allowed input size in characters. Inputs exceeding this limit are rejected before processing. Default is 1,048,576 (approximately 1 MB for ASCII).- Returns:
- the maximum input size in characters
-
getMaxNestingDepth
public int getMaxNestingDepth()Maximum allowed nesting depth for MJML elements. Exceeding this depth during parsing or rendering throws an exception. Default is 100.- Returns:
- the maximum nesting depth
-
getMaxIncludeDepth
public int getMaxIncludeDepth()Maximum allowed include nesting depth formj-include. Exceeding this depth during include resolution throws an exception. Default is 50.- Returns:
- the maximum include depth
-
getContentSanitizer
Returns the optional content sanitizer, ornullif none is configured. When set, the sanitizer is applied to the inner HTML content of<mj-text>,<mj-button>, and<mj-raw>elements before rendering.- Returns:
- the content sanitizer, or
nullif none is configured
-
toBuilder
Returns a builder pre-populated with this configuration's values.- Returns:
- a new builder initialized with this configuration's values
-
equals
-
hashCode
-
toString
-