Package org.thymeleaf

Interface ITemplateEngine

  • All Known Implementing Classes:
    TemplateEngine

    public interface ITemplateEngine

    Interface implemented by Thymeleaf Template Engines.

    Only one implementation of this interface is provided out-of-the-box: TemplateEngine. This interface is meant to be used for mocking or prototyping purposes.

    Since:
    3.0.0
    Author:
    Daniel Fernández
    See Also:
    TemplateEngine
    • Method Detail

      • getConfiguration

        IEngineConfiguration getConfiguration()

        Obtain the IEngineConfiguration the template engine is using (or will be using) for processing templates.

        Note that calling this method on a TemplateEngine implementation will effectively initialize the engine object, and therefore any modifications to the configuration will be forbidden from that moment.

        Returns:
        the engine configuration object.
      • process

        String process(String template,
                       IContext context)

        Process the specified template (usually the template name). Output will be written into a String that will be returned from calling this method, once template processing has finished.

        This is actually a convenience method that will internally create a TemplateSpec and then call process(TemplateSpec, IContext).

        Parameters:
        template - the template; depending on the template resolver this might be a template name or even the template contents (e.g. StringTemplateResolver).
        context - the context.
        Returns:
        a String containing the result of evaluating the specified template with the provided context.
      • process

        String process(String template,
                       Set<String> templateSelectors,
                       IContext context)

        Process the specified template (usually the template name) applying a set of template selectors. Output will be written into a String that will be returned from calling this method, once template processing has finished.

        Template selectors allow the possibility to process only a part of the specified template, expressing this selection in a syntax similar to jQuery, CSS or XPath selectors. Note this is only available for markup template modes (HTML, XML). For more info on template selectors syntax, have a look at AttoParser's markup selectors documentation.

        This is actually a convenience method that will internally create a TemplateSpec and then call process(TemplateSpec, IContext).

        Parameters:
        template - the template; depending on the template resolver this might be a template name or even the template contents (e.g. StringTemplateResolver).
        templateSelectors - the selectors to be used, defining the fragments that should be processed
        context - the context.
        Returns:
        a String containing the result of evaluating the specified template with the provided context.
      • process

        String process(TemplateSpec templateSpec,
                       IContext context)

        Process a template starting from a TemplateSpec. Output will be written into a String that will be returned from calling this method, once template processing has finished.

        The template specification will be used as input for the template resolvers, queried in chain until one of them resolves the template, which will then be executed.

        The context will contain the variables that will be available for the execution of expressions inside the template.

        Parameters:
        templateSpec - the template spec containing the template to be resolved (usually its name only), template selectors if they are to be applied, a template mode if it should be forced (instead of computing it at resolution time), and other attributes.
        context - the context.
        Returns:
        a String containing the result of evaluating the specified template with the provided context.
      • process

        void process(String template,
                     IContext context,
                     Writer writer)

        Process the specified template (usually the template name). Output will be written to the specified writer as it is generated from processing the template. This is specially useful for web environments (using ServletResponse.getWriter()).

        This is actually a convenience method that will internally create a TemplateSpec and then call process(TemplateSpec, IContext, Writer).

        Parameters:
        template - the template; depending on the template resolver this might be a template name or even the template contents (e.g. StringTemplateResolver).
        context - the context.
        writer - the writer the results will be output to.
      • process

        void process(String template,
                     Set<String> templateSelectors,
                     IContext context,
                     Writer writer)

        Process the specified template (usually the template name) applying a set of template selectors. Output will be written to the specified writer as it is generated from processing the template. This is specially useful for web environments (using ServletResponse.getWriter()).

        Template selectors allow the possibility to process only a part of the specified template, expressing this selection in a syntax similar to jQuery, CSS or XPath selectors. Note this is only available for markup template modes (HTML, XML). For more info on template selectors syntax, have a look at AttoParser's markup selectors documentation.

        This is actually a convenience method that will internally create a TemplateSpec and then call process(TemplateSpec, IContext, Writer).

        Parameters:
        template - the template; depending on the template resolver this might be a template name or even the template contents (e.g. StringTemplateResolver).
        templateSelectors - the selectors to be used, defining the fragments that should be processed. Can be null.
        context - the context.
        writer - the writer the results will be output to.
      • process

        void process(TemplateSpec templateSpec,
                     IContext context,
                     Writer writer)

        Process a template starting from a TemplateSpec. Output will be written to the specified writer as it is generated from processing the template. This is specially useful for web environments (using ServletResponse.getWriter()).

        The template specification will be used as input for the template resolvers, queried in chain until one of them resolves the template, which will then be executed.

        The context will contain the variables that will be available for the execution of expressions inside the template.

        Parameters:
        templateSpec - the template spec containing the template to be resolved (usually its name only), template selectors if they are to be applied, a template mode if it should be forced (instead of computing it at resolution time), and other attributes.
        context - the context.
        writer - the writer the results will be output to.
      • processThrottled

        IThrottledTemplateProcessor processThrottled(String template,
                                                     IContext context)

        Process the specified template (usually the template name). Output will be generated from processing the template as dictated by the returned IThrottledTemplateProcessor, and will be written to the output means specified to this throttled processor's methods. This is specially useful for scenarios such as reactive architectures in which the production of output could be regulated by a back-pressure mechanism.

        This is actually a convenience method that will internally create a TemplateSpec and then call process(TemplateSpec, IContext, Writer).

        Parameters:
        template - the template; depending on the template resolver this might be a template name or even the template contents (e.g. StringTemplateResolver).
        context - the context.
        Returns:
        the IThrottledTemplateProcessor object in charge of dictating the engine when to process the template and how much output should be produced.
      • processThrottled

        IThrottledTemplateProcessor processThrottled(String template,
                                                     Set<String> templateSelectors,
                                                     IContext context)

        Process the specified template (usually the template name) applying a set of template selectors. Output will be generated from processing the template as dictated by the returned IThrottledTemplateProcessor, and will be written to the output means specified to this throttled processor's methods. This is specially useful for scenarios such as reactive architectures in which the production of output could be regulated by a back-pressure mechanism.

        Template selectors allow the possibility to process only a part of the specified template, expressing this selection in a syntax similar to jQuery, CSS or XPath selectors. Note this is only available for markup template modes (HTML, XML). For more info on template selectors syntax, have a look at AttoParser's markup selectors documentation.

        This is actually a convenience method that will internally create a TemplateSpec and then call process(TemplateSpec, IContext, Writer).

        Parameters:
        template - the template; depending on the template resolver this might be a template name or even the template contents (e.g. StringTemplateResolver).
        templateSelectors - the selectors to be used, defining the fragments that should be processed. Can be null.
        context - the context.
        Returns:
        the IThrottledTemplateProcessor object in charge of dictating the engine when to process the template and how much output should be produced.
      • processThrottled

        IThrottledTemplateProcessor processThrottled(TemplateSpec templateSpec,
                                                     IContext context)

        Process a template starting from a TemplateSpec. Output will be generated from processing the template as dictated by the returned IThrottledTemplateProcessor, and will be written to the output means specified to this throttled processor's methods. This is specially useful for scenarios such as reactive architectures in which the production of output could be regulated by a back-pressure mechanism.

        The template specification will be used as input for the template resolvers, queried in chain until one of them resolves the template, which will then be executed.

        The context will contain the variables that will be available for the execution of expressions inside the template.

        Parameters:
        templateSpec - the template spec containing the template to be resolved (usually its name only), template selectors if they are to be applied, a template mode if it should be forced (instead of computing it at resolution time), and other attributes.
        context - the context.
        Returns:
        the IThrottledTemplateProcessor object in charge of dictating the engine when to process the template and how much output should be produced.