<dependencies>
<dependency>
<groupId>org.webmacro</groupId>
<artifactId>webmacro</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
html
<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h1>Hello, $name!</h1>
<p>Welcome to WebMacro!</p>
</body>
</html>
import java.io.StringWriter;
import org.webmacro.*;
import org.webmacro.servlet.*;
public class Main {
public static void main(String[] args) throws Exception {
WM wm = new DefaultWM();
String templatePath = "path/to/example.wm";
Template template = wm.getTemplate(templatePath);
Context context = new DefaultContext();
context.put("name", "John");
StringWriter output = new StringWriter();
template.generate(context, output);
System.out.println(output.toString());
}
}