Class AttributeContext
java.lang.Object
dev.jcputney.mjml.context.AttributeContext
Attribute cascade state gathered during head processing. Contains default attributes (from
<mj-attributes>), class attributes (from <mj-class>), and HTML attributes (from
<mj-html-attributes>).
This is one of three focused sub-contexts extracted from GlobalContext. See also
MetadataContext and StyleContext.
Thread safety: This class is not thread-safe. Each render pipeline creates its own instance.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new emptyAttributeContextwith no default, class, or HTML attributes. -
Method Summary
Modifier and TypeMethodDescriptionReturns the global default attributes defined under the "mj-all" tag.getClassAttributes(String className) Returns the class-level attributes for a given MJML class name.getDefaultAttributes(String tagName) Returns the default attributes for a given MJML tag name.Returns an unmodifiable view of all HTML attributes keyed by CSS selector.voidsetClassAttributes(String className, Map<String, String> attrs) Sets class-level attributes for a given MJML class name.voidsetDefaultAttributes(String tagName, Map<String, String> attrs) Sets default attributes for a given MJML tag name.voidsetHtmlAttributes(String selector, Map<String, String> attrs) Sets HTML attributes for a given CSS selector.
-
Constructor Details
-
AttributeContext
public AttributeContext()Creates a new emptyAttributeContextwith no default, class, or HTML attributes.
-
-
Method Details
-
setDefaultAttributes
Sets default attributes for a given MJML tag name. If attributes already exist for the tag, the new values are merged in.- Parameters:
tagName- the MJML tag name (e.g. "mj-all", "mj-section")attrs- the attribute name-value pairs to set
-
getDefaultAttributes
-
getAllDefaults
-
setClassAttributes
-
getClassAttributes
-
setHtmlAttributes
Sets HTML attributes for a given CSS selector. If attributes already exist for the selector, the new values are merged in.- Parameters:
selector- the CSS selector identifying target elementsattrs- the attribute name-value pairs to set
-
getHtmlAttributes
-