Class StTemplateRenderer

java.lang.Object
org.springframework.ai.template.st.StTemplateRenderer
All Implemented Interfaces:
BiFunction<String,Map<String,Object>,String>, TemplateRenderer

public class StTemplateRenderer extends Object implements TemplateRenderer
Renders a template using the StringTemplate (ST) v4 library.

This renderer allows customization of delimiters, validation behavior when template variables are missing, and how StringTemplate's built-in functions are handled during validation.

Use the builder() to create and configure instances.

Thread safety: This class is safe for concurrent use. Each call to apply(String, Map) creates a new StringTemplate instance, and no mutable state is shared between threads.

Since:
1.0.0
Author:
Thomas Vitale
  • Constructor Details

    • StTemplateRenderer

      public StTemplateRenderer(char startDelimiterToken, char endDelimiterToken, ValidationMode validationMode, boolean validateStFunctions)
      Constructs a new StTemplateRenderer with the specified delimiter tokens, validation mode, and function validation flag.
      Parameters:
      startDelimiterToken - the character used to denote the start of a template variable (e.g., '{')
      endDelimiterToken - the character used to denote the end of a template variable (e.g., '}')
      validationMode - the mode to use for template variable validation; must not be null
      validateStFunctions - whether to validate StringTemplate functions in the template
  • Method Details