Class BaseTemplateProcessor<T>

    • Constructor Detail

      • BaseTemplateProcessor

        public BaseTemplateProcessor()
    • Method Detail

      • process

        public String process​(Template template,
                              Map<String,​Object> data)
        Description copied from interface: TemplateProcessor
        Processes a template and returns the result as a string.
        Specified by:
        process in interface TemplateProcessor
        Parameters:
        template - the template to process.
        data - the data to use in the template
        Returns:
        the template process result.
      • processTemplate

        protected abstract String processTemplate​(T templateImplementation,
                                                  Map<String,​Object> data)
        Run a template implementation for specific data set.
        Parameters:
        templateImplementation - the template to process
        data - the data which should be passed to the template
        Returns:
        the template output
      • getTemplateImplementation

        protected T getTemplateImplementation​(Template template)
        Return the template language specific implementation of the template.
        Parameters:
        template - the template stored in the DB
        Returns:
        the template implementation in the template language
      • createTemplateSource

        protected String createTemplateSource​(Template template)
        Creates the template source taking into account overriding templates and pre-prending depends-on templates.
        Parameters:
        template - the template to create the source for
        Returns:
        a complete template source
        See Also:
        TemplateResolver.resolve(Template)
      • createSetFreeMarkerTemplateInCache

        protected T createSetFreeMarkerTemplateInCache​(Template template,
                                                       String source)
        Checks the cache if there is already a template implementation for a certain template. If so that one is returned. If not then a new implementation is created.
        Parameters:
        template -
        source -
      • createTemplateImplementation

        protected abstract T createTemplateImplementation​(Template template,
                                                          String source)
        To be implemented by the subclass. Based on the template from the DB and the complete template source, create a language specific template implementation instance.
        Parameters:
        template - the template object from the DB
        source - the complete source (after resolving and including all dependencies)
        Returns:
        the template implementation
      • readTemplateSourceFromClasspath

        protected String readTemplateSourceFromClasspath​(String path)
        Reads the template source from the classpath
        Parameters:
        path - the path to the template file
        Returns:
        the read template
      • clearCache

        public void clearCache()
        Description copied from interface: TemplateProcessor
        Is called by the kernel to signal that a template has changed and that TemplateProcessors should clear their cache and reload the templates.
        Specified by:
        clearCache in interface TemplateProcessor