Email.Mjml

HTML & web

MJML-shaped email layout trees.

Build a tree with mjml / section / column helpers (same authoring feel as Html), then render with toHtml and toText for Email.htmlMessage.

The renderer emits table-based, email-safe markup. There is no external mjml CLI — components compile in the BEAM runtime.

Types

Mjml

type Mjml = Mjml

An opaque email layout node.

Examples

Email.Mjml.text "Hello"

Values

text

text : String -> Mjml

A text node.

Examples

Email.Mjml.text "Hello"

node

node : String -> List Attribute -> List Mjml -> Mjml

A custom component by tag name.

Examples

Email.Mjml.node "custom" [] [ Email.Mjml.text "Hi" ]

void

void : String -> List Attribute -> Mjml

A void component (no children) by tag name.

Examples

Email.Mjml.void "image" [ Email.Mjml.Attributes.src "https://cdn/logo.png" ]

mjml

mjml : List Attribute -> List Mjml -> Mjml

Root document wrapper.

Examples

Email.Mjml.mjml [] [ Email.Mjml.body [] [] ]

body

body : List Attribute -> List Mjml -> Mjml

Message body container (centered width, background).

Examples

Email.Mjml.body [] [ Email.Mjml.section [] [] ]

section

section : List Attribute -> List Mjml -> Mjml

Full-width horizontal band.

Examples

Email.Mjml.section [] [ Email.Mjml.column [] [] ]

column

column : List Attribute -> List Mjml -> Mjml

Column inside a section.

Examples

Email.Mjml.column [] [ Email.Mjml.textBlock [] [] ]

textBlock

textBlock : List Attribute -> List Mjml -> Mjml

Styled text block (mj-text).

Examples

Email.Mjml.textBlock [] [ Email.Mjml.text "Hi" ]

button

button : List Attribute -> List Mjml -> Mjml

Call-to-action button (mj-button).

Examples

Email.Mjml.button [ Email.Mjml.Attributes.href "/confirm" ]
    [ Email.Mjml.text "Confirm" ]

image

image : List Attribute -> Mjml

Image (mj-image).

Examples

Email.Mjml.image [ Email.Mjml.Attributes.src "https://cdn/logo.png" ]

divider

divider : List Attribute -> Mjml

Horizontal rule (mj-divider).

Examples

Email.Mjml.divider []

spacer

spacer : List Attribute -> Mjml

Vertical gap (mj-spacer).

Examples

Email.Mjml.spacer [ Email.Mjml.Attributes.height "16" ]

toHtml

toHtml : Mjml -> String

Render to email-safe HTML.

Examples

Email.Mjml.toHtml tree

toText

toText : Mjml -> String

Render a simple plaintext alternative from the tree.

Examples

Email.Mjml.toText tree