Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.