Class MjmlService

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

public class MjmlService extends Object
Spring-managed service for rendering MJML templates to HTML.

This is a thin facade over a reusable MjmlRenderer instance created from the injected MjmlConfiguration.

  • Constructor Summary

    Constructors
    Constructor
    Description
    MjmlService(dev.jcputney.mjml.MjmlConfiguration configuration)
    Creates a service bound to the provided renderer configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    dev.jcputney.mjml.MjmlConfiguration
    Returns the configuration used by this service.
    render(String mjml)
    Renders an MJML template to HTML.
    dev.jcputney.mjml.MjmlRenderResult
    Renders an MJML template and returns the full result including metadata.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MjmlService

      public MjmlService(dev.jcputney.mjml.MjmlConfiguration configuration)
      Creates a service bound to the provided renderer configuration.
      Parameters:
      configuration - immutable renderer configuration
  • Method Details

    • render

      public String render(String mjml)
      Renders an MJML template to HTML.
      Parameters:
      mjml - the MJML source string
      Returns:
      the rendered HTML string
    • renderResult

      public dev.jcputney.mjml.MjmlRenderResult renderResult(String mjml)
      Renders an MJML template and returns the full result including metadata.
      Parameters:
      mjml - the MJML source string
      Returns:
      the render result containing HTML, title, and preview text
    • getConfiguration

      public dev.jcputney.mjml.MjmlConfiguration getConfiguration()
      Returns the configuration used by this service.
      Returns:
      active renderer configuration