org.melati.template.webmacro
Class WebmacroTemplateEngine

Package class diagram package WebmacroTemplateEngine
java.lang.Object
  extended by org.melati.template.AbstractTemplateEngine
      extended by org.melati.template.webmacro.WebmacroTemplateEngine
All Implemented Interfaces:
TemplateEngine
Direct Known Subclasses:
WebmacroServletTemplateEngine

public class WebmacroTemplateEngine
extends AbstractTemplateEngine
implements TemplateEngine

Wrapper for the WebMacro Template Engine for use with Melati.


Field Summary
static String NAME
          The name of the engine.
 org.webmacro.WM wm
          The WebMacro.
 
Fields inherited from class org.melati.template.AbstractTemplateEngine
roots
 
Constructor Summary
WebmacroTemplateEngine()
          Constructor.
 
Method Summary
 String expandedTemplate(Template template, TemplateContext templateContext)
          Expand the Template against the context and return the expansion as a string.
 void expandTemplate(MelatiWriter out, String templateName, TemplateContext templateContext)
          Expand the Template against the context.
 void expandTemplate(MelatiWriter out, Template template, TemplateContext templateContext)
          Expand the Template against the context.
 Object getEngine()
          Get the underlying engine.
 String getName()
          The name of the template engine (used to find the templets).
 MelatiStringWriter getStringWriter()
          Return a MelatiWebmacroStringWriter.
 TemplateContext getTemplateContext(Melati melati)
          Create a new, empty, Context for WebMacro.
 void init(MelatiConfig melatiConfig)
          Construct a new Engine.
 Template template(String templateName)
          Get a template given it's name.
 String templateExtension()
           
 
Methods inherited from class org.melati.template.AbstractTemplateEngine
addRoot, getRoots, getTemplateName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.melati.template.TemplateEngine
addRoot, getRoots, getTemplateName
 

Field Detail

NAME

public static final String NAME
The name of the engine.

See Also:
Constant Field Values

wm

public org.webmacro.WM wm
The WebMacro.

Constructor Detail

WebmacroTemplateEngine

public WebmacroTemplateEngine()
Constructor.

Method Detail

init

public void init(MelatiConfig melatiConfig)
          throws TemplateEngineException
Construct a new Engine.

Specified by:
init in interface TemplateEngine
Parameters:
melatiConfig - a MelatiConfig
Throws:
TemplateEngineException - if any problem occurs with the engine

getTemplateContext

public TemplateContext getTemplateContext(Melati melati)
Create a new, empty, Context for WebMacro.

Specified by:
getTemplateContext in interface TemplateEngine
Parameters:
melati - the Melati
Returns:
a TemplateContext

getName

public String getName()
The name of the template engine (used to find the templets).

Specified by:
getName in interface TemplateEngine
Returns:
the name of the current configured template engine

templateExtension

public String templateExtension()
Specified by:
templateExtension in interface TemplateEngine
Returns:
the extension of the templates used by WebMacro, including the dot.

template

public Template template(String templateName)
                  throws NotFoundException
Get a template given it's name.

Specified by:
template in interface TemplateEngine
Parameters:
templateName - the name of the template to find
Returns:
a template
Throws:
NotFoundException - if template not found

expandTemplate

public void expandTemplate(MelatiWriter out,
                           String templateName,
                           TemplateContext templateContext)
                    throws NotFoundException
Expand the Template against the context.

Specified by:
expandTemplate in interface TemplateEngine
Parameters:
out - a MelatiWriter to output on
templateName - the name of the template to expand
templateContext - the TemplateContext to expand the template against
Throws:
NotFoundException - if template not found

expandTemplate

public void expandTemplate(MelatiWriter out,
                           Template template,
                           TemplateContext templateContext)
Expand the Template against the context.

Specified by:
expandTemplate in interface TemplateEngine
Parameters:
out - a MelatiWriter to output on
template - the Template to expand
templateContext - the TemplateContext to expand the template against

expandedTemplate

public String expandedTemplate(Template template,
                               TemplateContext templateContext)
Expand the Template against the context and return the expansion as a string.

Specified by:
expandedTemplate in interface TemplateEngine
Parameters:
template - the Template to expand
templateContext - the ServletTemplateContext to expand the template against
Returns:
the interpolated template as a String
See Also:
TemplateEngine.expandedTemplate(org.melati.template.Template, org.melati.template.TemplateContext)

getStringWriter

public MelatiStringWriter getStringWriter()
Return a MelatiWebmacroStringWriter.

Specified by:
getStringWriter in interface TemplateEngine
Returns:
a MelatiStringWriter.
See Also:
Melati.getStringWriter(), TemplateEngine.getStringWriter()

getEngine

public Object getEngine()
Get the underlying engine.

Specified by:
getEngine in interface TemplateEngine
Returns:
the configured template engine


Copyright © 2000-2010 PanEris. All Rights Reserved.