Class AbstractSectionComponent
java.lang.Object
dev.jcputney.mjml.component.BaseComponent
dev.jcputney.mjml.component.BodyComponent
dev.jcputney.mjml.component.body.AbstractSectionComponent
Shared base class for
<mj-section> and <mj-wrapper>. Extracts identical
background-image, box-model, and style-building methods so that each subclass only overrides its
specific render logic.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ComponentRegistryThe component registry used to look up child components during rendering.Fields inherited from class BaseComponent
globalContext, node, renderContext -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSectionComponent(MjmlNode node, GlobalContext globalContext, RenderContext renderContext, ComponentRegistry registry) Creates a new section component with the given node, context, and registry. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddInnerTdBorderStyles(Map<String, String> styles) Adds border styles to the inner td style map.protected voidaddInnerTdExtraStyles(Map<String, String> styles) Adds extra styles between border-radius and font-size.protected voidaddInnerTdPaddingOverrides(Map<String, String> styles) Adds individual padding overrides.protected StringBuilds the CSS background shorthand string from this component's background attributes.protected StringBuilds the inline style string for the outer div when a background image is present.protected StringBuilds the inline style string for the inner table when a background image is present.protected StringBuilds the inline style string for the inner table element, including background color and optional border-collapse for border-radius support.protected StringBuilds the style for the inner td element.protected StringBuilds the outer div style with background color, max-width, and optional border-radius.Returns the box model for this component based on its padding and border attributes.protected StringReturns the value of the css-class attribute for this component.protected booleanChecks whether this component has a non-empty background-url attribute.protected StringrenderNormalScaffold(String vmlRect, String innerContent, String outerDivClass) Renders the normal (non-full-width) scaffold shared by mj-section and mj-wrapper.protected StringResolves background position from individual x/y properties or the combined property.Methods inherited from class BodyComponent
addBorderStyles, addIfPresent, addIfPresent, buildAttributes, buildResponsiveClass, buildStyle, escapeAttr, escapeHref, getChildrenByTags, getContentWidth, orderedMap, parseWidth, registerMediaQuery, render, renderChildren, resolveShorthandSide, sanitizeContent, sanitizeHrefMethods inherited from class BaseComponent
getAttribute, getAttribute, getDefaultAttributes, getNode, getTagName
-
Field Details
-
registry
The component registry used to look up child components during rendering.
-
-
Constructor Details
-
AbstractSectionComponent
protected AbstractSectionComponent(MjmlNode node, GlobalContext globalContext, RenderContext renderContext, ComponentRegistry registry) Creates a new section component with the given node, context, and registry.- Parameters:
node- the MJML node representing this componentglobalContext- the global rendering contextrenderContext- the current render contextregistry- the component registry for resolving child components
-
-
Method Details
-
getBoxModel
Description copied from class:BodyComponentReturns the box model for this component based on its padding and border attributes. The result is cached for repeated access within the same render call.- Overrides:
getBoxModelin classBodyComponent- Returns:
- the CSS box model for this component
-
hasBackgroundUrl
protected boolean hasBackgroundUrl()Checks whether this component has a non-empty background-url attribute.- Returns:
trueif a background URL is set,falseotherwise
-
resolveBackgroundPosition
Resolves background position from individual x/y properties or the combined property. Normalizes "top center" to "center top" format.- Returns:
- the normalized background position string in "x y" format
-
buildBackgroundCss
Builds the CSS background shorthand string from this component's background attributes.- Returns:
- the CSS background shorthand value
-
buildBgImageDivStyle
Builds the inline style string for the outer div when a background image is present.- Returns:
- the inline CSS style string for the background image div
-
buildBgImageTableStyle
Builds the inline style string for the inner table when a background image is present.- Returns:
- the inline CSS style string for the background image table
-
getCssClass
Returns the value of the css-class attribute for this component.- Returns:
- the CSS class string, or an empty string if not set
-
buildInnerTableStyle
Builds the inline style string for the inner table element, including background color and optional border-collapse for border-radius support.- Returns:
- the inline CSS style string for the inner table
-
buildInnerTdStyle
Builds the style for the inner td element. Subclasses can overrideaddInnerTdBorderStyles(Map)andaddInnerTdExtraStyles(Map)to customize border handling and add extra properties.- Returns:
- the inline CSS style string for the inner td element
-
addInnerTdBorderStyles
Adds border styles to the inner td style map. Default implementation adds only the "border" attribute if non-empty and not "none". Subclasses can override to use the full addBorderStyles() helper.- Parameters:
styles- the mutable style map to add border properties to
-
addInnerTdExtraStyles
-
addInnerTdPaddingOverrides
-
renderNormalScaffold
Renders the normal (non-full-width) scaffold shared by mj-section and mj-wrapper. Both components follow the same MSO table → VML rect → div/table → inner content → close structure; subclasses provide the VML rect string, inner content, and optional css-class on the outer div.- Parameters:
vmlRect- VML rect markup for background images (from VmlHelper)innerContent- rendered inner content (columns for section, wrapped children for wrapper)outerDivClass- optional CSS class to add to the outer div (empty string if none)- Returns:
- the rendered HTML scaffold string
-
buildOuterDivStyle
Builds the outer div style with background color, max-width, and optional border-radius. Used by both mj-section (as buildSectionStyle) and mj-wrapper (as buildWrapperStyle).- Returns:
- the inline CSS style string for the outer div
-