Class ClasspathIncludeResolver
java.lang.Object
dev.jcputney.mjml.ClasspathIncludeResolver
- All Implemented Interfaces:
IncludeResolver
Resolves mj-include paths from the classpath.
Usage
MjmlConfiguration config = MjmlConfiguration.builder()
.includeResolver(new ClasspathIncludeResolver())
.build();
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a resolver that uses the thread's context class loader.ClasspathIncludeResolver(ClassLoader classLoader) Creates a resolver that uses the given class loader. -
Method Summary
Modifier and TypeMethodDescriptionresolve(String path, ResolverContext context) Resolves the given path to its content.
-
Constructor Details
-
ClasspathIncludeResolver
public ClasspathIncludeResolver()Creates a resolver that uses the thread's context class loader. -
ClasspathIncludeResolver
Creates a resolver that uses the given class loader.- Parameters:
classLoader- the class loader to use for resource lookups
-
-
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
-