Class TemplateMgr
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TemplatePage
Returns a runnable page template, alias for thegetTemplate(java.io.File)
method.static TemplatePage
Returns a runnable page template, alias for thegetTemplate(java.lang.String)
method.static TemplatePage
getTemplate
(File templateFile) Returns a runnable page template.static TemplatePage
getTemplate
(String templateFilePath) Returns a runnable page template.static void
Interactive page manager use for testing.
-
Constructor Details
-
TemplateMgr
public TemplateMgr()
-
-
Method Details
-
get
Returns a runnable page template, alias for thegetTemplate(java.lang.String)
method.- Parameters:
templateFile
- the full path to the template file- Throws:
Exception
-
get
Returns a runnable page template, alias for thegetTemplate(java.io.File)
method.- Parameters:
templateFile
- the full path to the template file- Throws:
Exception
-
getTemplate
Returns a runnable page template.- Parameters:
templateFile
- the full path to the template file- Throws:
Exception
-
getTemplate
Returns a runnable page template.- Parameters:
templateFile
- the template file- Throws:
Exception
-
main
-