Class ClasspathIncludeResolver

java.lang.Object
dev.jcputney.mjml.ClasspathIncludeResolver
All Implemented Interfaces:
IncludeResolver

public final class ClasspathIncludeResolver extends Object implements IncludeResolver
Resolves mj-include paths from the classpath.

Usage

MjmlConfiguration config = MjmlConfiguration.builder()
    .includeResolver(new ClasspathIncludeResolver())
    .build();
  • Constructor Details

    • ClasspathIncludeResolver

      public ClasspathIncludeResolver()
      Creates a resolver that uses the thread's context class loader.
    • ClasspathIncludeResolver

      public ClasspathIncludeResolver(ClassLoader classLoader)
      Creates a resolver that uses the given class loader.
      Parameters:
      classLoader - the class loader to use for resource lookups
  • Method Details

    • resolve

      public String resolve(String path, ResolverContext context)
      Description copied from interface: IncludeResolver
      Resolves the given path to its content.

      Security note: Implementations should validate paths to prevent directory traversal attacks (e.g., paths containing "../" sequences).

      Specified by:
      resolve in interface IncludeResolver
      Parameters:
      path - the include path from the mj-include element
      context - metadata about the include chain (including path, type, depth)
      Returns:
      the resolved content string