public final class TemplateMgr extends Object
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);
Constructor and Description |
---|
TemplateMgr() |
Modifier and Type | Method and Description |
---|---|
static TemplatePage |
get(File templateFile)
Returns a runnable page template, alias for the
getTemplate(File) method. |
static TemplatePage |
get(String templateFilePath)
Returns a runnable page template, alias for the
getTemplate(String) method. |
static TemplatePage |
getTemplate(File templateFile)
Returns a runnable page template.
|
static TemplatePage |
getTemplate(String templateFilePath)
Returns a runnable page template.
|
static void |
main(String[] args)
Interactive page manager use for testing.
|
public TemplateMgr()
public static TemplatePage get(String templateFilePath) throws Exception
getTemplate(String)
method.templateFile
- the full path to the template fileException
public static TemplatePage get(File templateFile) throws Exception
getTemplate(File)
method.templateFile
- the full path to the template fileException
public static TemplatePage getTemplate(String templateFilePath) throws Exception
templateFile
- the full path to the template fileException
public static TemplatePage getTemplate(File templateFile) throws Exception
templateFile
- the template fileException