Documentation
¶
Index ¶
- func DefaultSkeleton(headRaw string, content string, ctx *MJMLContext) (string, error)
- type Attribute
- type Attributes
- type BaseComponent
- func (c *BaseComponent) GetAttribute(name string) *string
- func (c *BaseComponent) GetAttributeOr(name string, orValue string) string
- func (c *BaseComponent) GetChildren() []Component
- func (c *BaseComponent) GetContent() string
- func (c *BaseComponent) IsRawElement() bool
- func (c *BaseComponent) RenderMJML(w MJMLWriter, xml string) error
- type BodyComponent
- func (c *BodyComponent) CreateChildren(children []*parser.MJMLNode, options *CreateChildrenOptions) ([]Component, error)
- func (c *BodyComponent) GetBoxWidths() BoxWidths
- func (c *BodyComponent) GetShorthandAttrValue(attribute string, direction string) int
- func (c *BodyComponent) GetShorthandBorderValue(attribute string, direction string) int
- type BoxWidths
- type Component
- type ComponentProps
- type ComponentSpec
- type CreateChildrenOptions
- type GlobalData
- type HeadComponent
- type HtmlAttribute
- type HtmlAttributes
- type MJMLBuilder
- type MJMLContext
- func (c *MJMLContext) AddComponentHeadSyle(styleFunc func(breakpoint string) string)
- func (c *MJMLContext) AddFont(name string, href string)
- func (c *MJMLContext) AddHeadStyle(name string, styleFunc func(breakpoint string) string)
- func (c *MJMLContext) AddHtmlAttributes(path string, attributes []HtmlAttribute)
- func (c *MJMLContext) AddMediaQuery(className string, value float64, unit string)
- func (c *MJMLContext) AddPreview(preview string)
- func (c *MJMLContext) AddStyle(css string, inline bool)
- func (c *MJMLContext) GetAttributes(node *parser.MJMLNode) *Attributes
- type MJMLOptions
- type MJMLWriter
- type Style
- type ValidationLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSkeleton ¶
func DefaultSkeleton(headRaw string, content string, ctx *MJMLContext) (string, error)
Types ¶
type Attributes ¶
type Attributes = orderedmap.OrderedMap[string, string]
type BaseComponent ¶
type BaseComponent struct {
Node *parser.MJMLNode
Spec *ComponentSpec
Props *ComponentProps
Context *MJMLContext
Attributes *Attributes
Children []Component
}
func NewBaseComponent ¶
func NewBaseComponent(node *parser.MJMLNode, spec *ComponentSpec, props *ComponentProps, context *MJMLContext) *BaseComponent
func (*BaseComponent) GetAttribute ¶
func (c *BaseComponent) GetAttribute(name string) *string
func (*BaseComponent) GetAttributeOr ¶
func (c *BaseComponent) GetAttributeOr(name string, orValue string) string
func (*BaseComponent) GetChildren ¶
func (c *BaseComponent) GetChildren() []Component
func (*BaseComponent) GetContent ¶
func (c *BaseComponent) GetContent() string
func (*BaseComponent) IsRawElement ¶
func (c *BaseComponent) IsRawElement() bool
func (*BaseComponent) RenderMJML ¶
func (c *BaseComponent) RenderMJML(w MJMLWriter, xml string) error
type BodyComponent ¶
type BodyComponent struct {
*BaseComponent
Component Component
}
func NewBodyComponent ¶
func NewBodyComponent(node *parser.MJMLNode, spec *ComponentSpec, props *ComponentProps, context *MJMLContext) *BodyComponent
func (*BodyComponent) CreateChildren ¶
func (c *BodyComponent) CreateChildren(children []*parser.MJMLNode, options *CreateChildrenOptions) ([]Component, error)
func (*BodyComponent) GetBoxWidths ¶
func (c *BodyComponent) GetBoxWidths() BoxWidths
func (*BodyComponent) GetShorthandAttrValue ¶
func (c *BodyComponent) GetShorthandAttrValue(attribute string, direction string) int
func (*BodyComponent) GetShorthandBorderValue ¶
func (c *BodyComponent) GetShorthandBorderValue(attribute string, direction string) int
type Component ¶
type Component interface {
GetStyles(element string) []*Style
GetAttribute(name string) *string
GetAttributeOr(name string, orValue string) string
GetChildContext() *MJMLContext
IsRawElement() bool
Render(w MJMLWriter) error
}
func InitComponent ¶
func InitComponent(node *parser.MJMLNode, props *ComponentProps, context *MJMLContext) (Component, error)
type ComponentProps ¶
type ComponentSpec ¶
type ComponentSpec struct {
TagName string
EndingTag bool
AllowedAttributes map[string]string
DefaultAttributes []*Attribute
Dependencies map[string][]string
IsRawElement bool
Create func(node *parser.MJMLNode, spec *ComponentSpec, props *ComponentProps, context *MJMLContext) (Component, error)
}
type CreateChildrenOptions ¶
type CreateChildrenOptions struct {
Attributes []*Attribute
}
type GlobalData ¶
type GlobalData struct {
BackgroundColor *string
BeforeDoctype string
Breakpoint string
Classes map[string]*Attributes
DefaultAttributes map[string]*Attributes
HtmlAttributes []*HtmlAttributes
Fonts []*helpers.FontDeclaration
InlineStyles []string
HeadStyles map[string]func(breakpoint string) string
ComponentsHeadStyles []func(breakpoint string) string
MediaQueries *Attributes
Preview *string
Styles []string
Title *string
ForceOWADesktop bool
Lang string
Dir string
Data map[string]any
}
type HeadComponent ¶
type HeadComponent struct {
*BaseComponent
Component Component
}
func NewHeadComponent ¶
func NewHeadComponent(node *parser.MJMLNode, spec *ComponentSpec, props *ComponentProps, context *MJMLContext) *HeadComponent
func (*HeadComponent) CreateChildren ¶
func (c *HeadComponent) CreateChildren() ([]Component, error)
type HtmlAttribute ¶
type HtmlAttributes ¶
type HtmlAttributes struct {
Path string
Attributes []HtmlAttribute
}
type MJMLBuilder ¶
func (*MJMLBuilder) WriteConditionalTag ¶
func (b *MJMLBuilder) WriteConditionalTag(s string, negation bool) (int, error)
func (*MJMLBuilder) WriteMsoConditionalTag ¶
func (b *MJMLBuilder) WriteMsoConditionalTag(s string, negation bool) (int, error)
type MJMLContext ¶
type MJMLContext struct {
Components map[string]*ComponentSpec
RawComponents []string
ContainerWidth int
PrinterSupport bool
GlobalData *GlobalData
Processing func(w MJMLWriter, xml string, context *MJMLContext) error
}
func (*MJMLContext) AddComponentHeadSyle ¶
func (c *MJMLContext) AddComponentHeadSyle(styleFunc func(breakpoint string) string)
func (*MJMLContext) AddFont ¶
func (c *MJMLContext) AddFont(name string, href string)
func (*MJMLContext) AddHeadStyle ¶
func (c *MJMLContext) AddHeadStyle(name string, styleFunc func(breakpoint string) string)
func (*MJMLContext) AddHtmlAttributes ¶
func (c *MJMLContext) AddHtmlAttributes(path string, attributes []HtmlAttribute)
func (*MJMLContext) AddMediaQuery ¶
func (c *MJMLContext) AddMediaQuery(className string, value float64, unit string)
func (*MJMLContext) AddPreview ¶
func (c *MJMLContext) AddPreview(preview string)
func (*MJMLContext) AddStyle ¶
func (c *MJMLContext) AddStyle(css string, inline bool)
func (*MJMLContext) GetAttributes ¶
func (c *MJMLContext) GetAttributes(node *parser.MJMLNode) *Attributes
type MJMLOptions ¶
type MJMLWriter ¶
type ValidationLevel ¶
type ValidationLevel string
const ( ValidationLevelStrict ValidationLevel = "strict" ValidationLevelSoft ValidationLevel = "soft" ValidationLevelSkip ValidationLevel = "skip" )
Click to show internal directories.
Click to hide internal directories.