mjml

package
v0.18.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(ctx context.Context, mjmlPath string, opts CompileOptions) (string, error)

func ProcessDirectory

func ProcessDirectory(ctx context.Context, rootDir string, opts CompileOptions) error

ProcessDirectory walks through a directory and compiles all MJML files

Types

type CompileOptions

type CompileOptions struct {
	// When true, passes --config.allowIncludes=true to mjml so that
	// <mj-include> directives are processed. MJML 5 ignores them by default.
	AllowIncludes bool
	// Allowlist of directories that mj-include is permitted to read from, on
	// top of the directory of the file being compiled. Values are forwarded to
	// mjml verbatim as --config.includePath=[...]; relative paths are resolved
	// by mjml against its own working directory, so callers should pass
	// absolute paths. Setting any value implies AllowIncludes.
	IncludePaths []string
}

CompileOptions controls how the underlying mjml CLI is invoked.

func NewCompileOptions

func NewCompileOptions(searchPathRoot string, allowIncludes bool, extraIncludePaths []string) CompileOptions

NewCompileOptions builds CompileOptions for files compiled inside the given search-path root. When mj-include is in use, searchPathRoot is automatically allowlisted so that templates can include any partial inside the same search path (e.g. a sibling _includes/ folder) without having to enumerate each directory. extraIncludePaths are appended after the search-path root.

When both allowIncludes is false and extraIncludePaths is empty, the returned CompileOptions is the zero value and no include flags are forwarded to mjml.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL