<dependency>
<groupId>org.chunkframework</groupId>
<artifactId>chunk-core</artifactId>
<version>1.0.0</version>
</dependency>
<html>
<head>
</head>
<body>
{{#if user }}
{{ else }}
{{/if}}
</body>
</html>
import org.chunkframework.core.TemplateEngine;
import org.chunkframework.core.Template;
import java.util.HashMap;
import java.util.Map;
public class DataFormatter {
public static void main(String[] args) {
TemplateEngine engine = new TemplateEngine();
Template template = engine.parseTemplate("/path/to/example.chunk");
Map<String, Object> variables = new HashMap<>();
variables.put("user", new User("John Doe", 25));
String output = template.render(variables);
System.out.println(output);
}
}
class User {
private String name;
private int age;
public User(String name, int age) {
this.name = name;
this.age = age;
}
}
<html>
<head>
</head>
<body>
</body>
</html>