fc.util.pagetemplate
Class TemplateMgr

java.lang.Object
  extended by 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);


Constructor Summary
TemplateMgr()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateMgr

public TemplateMgr()
Method Detail

get

public static TemplatePage get(String templateFilePath)
                        throws Exception
Returns a runnable page template, alias for the getTemplate(String) method.

Parameters:
templateFile - the full path to the template file
Throws:
Exception

get

public static TemplatePage get(File templateFile)
                        throws Exception
Returns a runnable page template, alias for the getTemplate(File) method.

Parameters:
templateFile - the full path to the template file
Throws:
Exception

getTemplate

public static TemplatePage getTemplate(String templateFilePath)
                                throws Exception
Returns a runnable page template.

Parameters:
templateFile - the full path to the template file
Throws:
Exception

getTemplate

public static TemplatePage getTemplate(File templateFile)
                                throws Exception
Returns a runnable page template.

Parameters:
templateFile - the template file
Throws:
Exception

main

public static void main(String[] args)
                 throws Exception
Interactive page manager use for testing.

Throws:
Exception