Merging the template with the data-model

As we know, data-model + template = output, and we have a data-model (root) and a template (temp), so to get the output we have to merge them. This is done by the process method of the template. It takes the data-model root and a Writer as parameters. It writes the produced output to the Writer. For the sake of simplicity here I write to the standard output:

Writer out = new OutputStreamWriter(System.out);
temp.process(root, out);  

This will print to your terminal the output what you have seen in the first example of the Template Author's Guide.

Once you have obtained a Template instance, you can merge it with different data-models for unlimited times (Template instances are basically stateless). Also, the test.ftl file is accessed only while the Template instance is created, not when you call the process method.

FreeMarker Manual -- For FreeMarker 2.3.20
HTML generated: 2013-06-27 20:54:33 GMT
Edited with XMLMind XML Editor
Here!