java.lang.Object
com.renomad.minum.templating.TemplateProcessor
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 Summary
Modifier and TypeMethodDescriptionstatic TemplateProcessor
buildProcessor
(String template) Builds aTemplateProcessor
from a string containing a proper template.renderTemplate
(Map<String, String> myMap) Given a map of key names -> value, render a template.
-
Method Details
-
renderTemplate
Given a map of key names -> value, render a template. -
buildProcessor
Builds aTemplateProcessor
from a string containing a proper template. Templated values are surrounded by double-curly-braces, i.e. {{foo}} or {{ foo }}
-