Class FreeMarkerTemplateManager

java.lang.Object
org.javalite.activeweb.TemplateManager
org.javalite.activeweb.freemarker.FreeMarkerTemplateManager

public class FreeMarkerTemplateManager extends TemplateManager
Author:
Igor Polevoy
  • Constructor Details

    • FreeMarkerTemplateManager

      public FreeMarkerTemplateManager()
  • Method Details

    • merge

      public void merge(Map<String,​Object> values, String template, Writer writer, boolean customRoute)
      Description copied from class: TemplateManager
      Specified by:
      merge in class TemplateManager
    • 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 class TemplateManager
      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 class TemplateManager
      Parameters:
      ctx - servlet context
    • setTemplateClassPath

      public void setTemplateClassPath(String path) throws IOException
      This method exists for testing.
      Parameters:
      path - path to directory with test templates.
      Throws:
      IOException - exception if directory not present.
    • setDefaultLayout

      public void setDefaultLayout(String layoutPath)
    • setTemplateLocation

      public void setTemplateLocation(String templateLocation)
      Specified by:
      setTemplateLocation in class TemplateManager
      Parameters:
      templateLocation - this can be absolute or relative.
    • registerTag

      public void registerTag(String name, FreeMarkerTag tag)
      Registers an application-specific tag.
      Parameters:
      name - name of tag.
      tag - tag instance.
    • getTag

      public FreeMarkerTag getTag(String tagName)
      Returns an instance of FreeMarkerTag. Use this method to further configure specific tags.
      Parameters:
      tagName - name of tag as used in a template
      Returns:
      instance of registered tag