Class TemplateMgr

java.lang.Object
fc.util.pagetemplate.TemplateMgr

public final class TemplateMgr extends Object
A page template is a simplified molly page, that runs in a non web environment. Good for creating dynamic web pages (for email campaigns, etc) from the command line.

There is another alternate/simpler template mechanism here: Template.

The page template loads template files (can have any suffix but .template is suggested as opposed to .mp to keep the non-web distinction clear). The template file is compiled (uses the system temp directory for compilation) as needed and the resulting class file is loaded/run. If a template is changed, it is automatically recompiled, reloaded and rerun. If the template has a compilation error, that page remains unloaded until the error is fixed.

The output of the template is written to an output destination (could be a buffer, string, file, etc) and the invoker can then send that output to an email destination.

Template pages only use the system classpath for compilation. Pages can refer to any class found in the system classpath.

Here is some sample usage:

TemplatePage pt = TemplateMgr.getTemplate("/path/to/file.template");
pt.render(new File("/path/to/output.file"));

//To optionally send information to the page, you can say (before calling render):
Map m = new HashMap();
m.put(...whatever..);
pt.setContext(m);