Class BaseComponent
java.lang.Object
dev.jcputney.mjml.component.BaseComponent
- Direct Known Subclasses:
BodyComponent, HeadComponent
Abstract base class for all MJML components. Sealed to permit only BodyComponent and
HeadComponent subtypes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final GlobalContextThe global rendering context shared across all components.protected final MjmlNodeThe parsed MJML node backing this component.protected final RenderContextThe render-phase context for the current rendering pass. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseComponent(MjmlNode node, GlobalContext globalContext, RenderContext renderContext) Creates a new component bound to the given node and contexts. -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(String name) Resolves an attribute value using the 5-level cascade.getAttribute(String name, String defaultValue) Resolves an attribute value, returning the provided default if not found.Returns the default attribute values for this component.getNode()Returns the parsed MJML node backing this component.abstract StringReturns the MJML tag name this component handles.
-
Field Details
-
node
The parsed MJML node backing this component. -
globalContext
The global rendering context shared across all components. -
renderContext
The render-phase context for the current rendering pass.
-
-
Constructor Details
-
BaseComponent
Creates a new component bound to the given node and contexts.- Parameters:
node- the parsed MJML nodeglobalContext- the global rendering contextrenderContext- the render-phase context
-
-
Method Details
-
getTagName
Returns the MJML tag name this component handles.- Returns:
- the MJML tag name
-
getDefaultAttributes
-
getAttribute
-
getAttribute
Resolves an attribute value, returning the provided default if not found.- Parameters:
name- the attribute name to resolvedefaultValue- the value to return if the attribute is not found- Returns:
- the resolved attribute value, or
defaultValueif not found
-
getNode
Returns the parsed MJML node backing this component.- Returns:
- the MJML node
-