Get the template

Templates are represented by freemarker.template.Template instances. Typically you obtain a Template instance from the Configuration instance. Whenever you need a template instance you can get it with its getTemplate method. Store the example template in the test.ftl file of the earlier set directory, then you can do this:

Template temp = cfg.getTemplate("test.ftl");  

When you call this, it will create a Template instance corresponds to test.ftl, by reading /where/you/store/templates/test.ftl and parsing (compile) it. The Template instance stores the template in the parsed form, and not as text.

Configuration caches Template instances, so when you get test.ftl again, it probably will not create new Template instance (thus doesn't read and parse the file), just returns the same instance as for the first time.

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