Class TemplateProcessor

java.lang.Object
com.renomad.minum.templating.TemplateProcessor

public final class TemplateProcessor extends Object
This class provides methods for working with templates.

The first step is to write a template. Here is an example:

 Hello, my name is {{name}}
 

Then, feed that string into the buildProcessor(java.lang.String) method, like this:

 
   String input = "Hello, my name is {{name}}"
   TemplateProcessor helloProcessor = TemplateProcessor.buildProcessor(input);
 
 

The returned value ("helloProcessor") can be rendered with different values. For example:

 
   Map<String,String> myMap = Map.of("name", "Susanne");
   String fullyRenderedString = helloProcessor.renderTemplate(myMap);
 
 

The result is:

     Hello, my name is Susanne
 
  • Method Details

    • renderTemplate

      public String renderTemplate(Map<String,String> myMap)
      Given a map of key names -> value, render a template.
    • buildProcessor

      public static TemplateProcessor buildProcessor(String template)
      Builds a TemplateProcessor from a string containing a proper template. Templated values are surrounded by double-curly-braces, i.e. {{foo}} or {{ foo }}