Using template

Sooner or later you will need to generate documents (HTML, PDF…). Void Framework provides all the tools you need!


Example

public class TemplateExample {

    private final TemplateRenderer templateRenderer;

    @Inject
    public TemplateExample(final TemplateRenderer templateRenderer) {

        this.templateRenderer = templateRenderer;
    }

    public void renderTemplate() {

        final Map<String, Object> dataModel = new HashMap<>();
        dataModel.put("greating.msg", "Hello World!")

        final String result = templateRenderer.render(
            "renderWithDataModel.ftl",
            Locale.ENGLISH,
            dataModel);

        System.out.println(result);
    }
}