Class DelimitingTemplateLoader

  • All Implemented Interfaces:
    freemarker.cache.TemplateLoader

    public class DelimitingTemplateLoader
    extends Object
    implements freemarker.cache.TemplateLoader
    Wrap a TemplateLoader, so each time a template is read, delimiters will be inserted at the beginning and end. This makes it easier for a developer can see what lines of HTML come from which templates. TemplateLoader returns a token object when finding a template, and then recognizes that object when it is used as an argument to getLastModified() or getReader(). In order to keep track of the template name, we wrap the token object and the name in a token of our own. Taking the easy way out and reading in the entire template into a string. This limits the template size to less than 2^31 characters (~2 GBytes). That seems adequate.
    • Constructor Detail

      • DelimitingTemplateLoader

        public DelimitingTemplateLoader​(freemarker.cache.TemplateLoader innerLoader)
    • Method Detail

      • findTemplateSource

        public Object findTemplateSource​(String name)
                                  throws IOException
        Specified by:
        findTemplateSource in interface freemarker.cache.TemplateLoader
        Throws:
        IOException
      • getLastModified

        public long getLastModified​(Object templateSource)
        Specified by:
        getLastModified in interface freemarker.cache.TemplateLoader
      • closeTemplateSource

        public void closeTemplateSource​(Object templateSource)
                                 throws IOException
        Specified by:
        closeTemplateSource in interface freemarker.cache.TemplateLoader
        Throws:
        IOException