Class ThymeleafMjmlService

java.lang.Object
dev.jcputney.mjml.spring.ThymeleafMjmlService

public class ThymeleafMjmlService extends Object
Service that combines Thymeleaf template processing with MJML rendering. First processes Thymeleaf expressions, then renders the resulting MJML to HTML.
  • Constructor Details

    • ThymeleafMjmlService

      public ThymeleafMjmlService(org.thymeleaf.TemplateEngine templateEngine, MjmlService mjmlService)
      Creates a Thymeleaf + MJML composition service.
      Parameters:
      templateEngine - Thymeleaf engine used for template processing
      mjmlService - MJML rendering service applied to processed template output
  • Method Details

    • render

      public String render(String mjmlTemplate, Map<String,Object> variables)
      Processes an inline MJML template string through Thymeleaf, then renders to HTML.
      Parameters:
      mjmlTemplate - the MJML template string with Thymeleaf expressions
      variables - the template variables
      Returns:
      the rendered HTML string
    • renderTemplate

      public String renderTemplate(String templateName, Map<String,Object> variables)
      Loads a template by name via Thymeleaf, processes it, then renders as MJML to HTML.
      Parameters:
      templateName - the Thymeleaf template name
      variables - the template variables
      Returns:
      the rendered HTML string