Class FileSystemIncludeResolver
java.lang.Object
dev.jcputney.mjml.FileSystemIncludeResolver
- All Implemented Interfaces:
IncludeResolver
Resolves mj-include paths from the file system relative to a base directory.
Usage
MjmlConfiguration config = MjmlConfiguration.builder()
.includeResolver(new FileSystemIncludeResolver(Path.of("/templates")))
.build();
-
Constructor Summary
ConstructorsConstructorDescriptionFileSystemIncludeResolver(Path baseDir) Creates a resolver that resolves paths relative to the given base directory. -
Method Summary
Modifier and TypeMethodDescriptionresolve(String path, ResolverContext context) Resolves the given path to its content.
-
Constructor Details
-
FileSystemIncludeResolver
Creates a resolver that resolves paths relative to the given base directory.- Parameters:
baseDir- the base directory for relative include paths
-
-
Method Details
-
resolve
Description copied from interface:IncludeResolverResolves the given path to its content.Security note: Implementations should validate paths to prevent directory traversal attacks (e.g., paths containing "../" sequences).
- Specified by:
resolvein interfaceIncludeResolver- Parameters:
path- the include path from the mj-include elementcontext- metadata about the include chain (including path, type, depth)- Returns:
- the resolved content string
-