Class FreeMarkerTemplateManager
java.lang.Object
org.javalite.activeweb.TemplateManager
org.javalite.activeweb.freemarker.FreeMarkerTemplateManager
- Author:
- Igor Polevoy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns an instance ofFreeMarkerTag
.void
Same asTemplateManager.merge(java.util.Map, String, String, String, java.io.Writer, boolean customRoute)
, but uses default layout and default format (html).void
merge(Map<String,Object> input, String template, String layout, String format, Writer writer, boolean customRoute)
Merges values with templates and writes a merged template to the writer.void
registerTag(String name, FreeMarkerTag tag)
Registers an application-specific tag.void
setDefaultLayout(String layoutPath)
void
setServletContext(javax.servlet.ServletContext ctx)
A template manager might need a context to be able to load templates from it.void
setTemplateClassPath(String path)
This method exists for testing.void
setTemplateLocation(String templateLocation)
Methods inherited from class org.javalite.activeweb.TemplateManager
sessionId
-
Constructor Details
-
FreeMarkerTemplateManager
public FreeMarkerTemplateManager()
-
-
Method Details
-
merge
Description copied from class:TemplateManager
Same asTemplateManager.merge(java.util.Map, String, String, String, java.io.Writer, boolean customRoute)
, but uses default layout and default format (html).- Specified by:
merge
in classTemplateManager
-
merge
public void merge(Map<String,Object> input, String template, String layout, String format, Writer writer, boolean customRoute)Description copied from class:TemplateManager
Merges values with templates and writes a merged template to the writer.- Specified by:
merge
in classTemplateManager
- Parameters:
input
- values to be merged.template
- name of template in format:dir/template
without file extension. This is to support multiple template technologies in the future.layout
- name of layout,null
if no layout is needed.writer
- Writer to write results to.customRoute
- true if the route is custom. In this case, the template manager will not try to guess a template name based on a format
-
setServletContext
public void setServletContext(javax.servlet.ServletContext ctx)Description copied from class:TemplateManager
A template manager might need a context to be able to load templates from it.- Specified by:
setServletContext
in classTemplateManager
- Parameters:
ctx
- servlet context
-
setTemplateClassPath
This method exists for testing.- Parameters:
path
- path to directory with test templates.- Throws:
IOException
- exception if directory not present.
-
setDefaultLayout
-
setTemplateLocation
- Specified by:
setTemplateLocation
in classTemplateManager
- Parameters:
templateLocation
- this can be absolute or relative.
-
registerTag
Registers an application-specific tag.- Parameters:
name
- name of tag.tag
- tag instance.
-
getTag
Returns an instance ofFreeMarkerTag
. Use this method to further configure specific tags.- Parameters:
tagName
- name of tag as used in a template- Returns:
- instance of registered tag
-