Class ScriptTemplateConfigurer

  • All Implemented Interfaces:
    ScriptTemplateConfig

    public class ScriptTemplateConfigurer
    extends Object
    implements ScriptTemplateConfig
    An implementation of Spring MVC's ScriptTemplateConfig for creating a ScriptEngine for use in a web application.
    
     // Add the following to an @Configuration class
     @Bean
     public ScriptTemplateConfigurer mustacheConfigurer() {
        ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
        configurer.setEngineName("nashorn");
        configurer.setScripts("mustache.js");
        configurer.setRenderObject("Mustache");
        configurer.setRenderFunction("render");
        return configurer;
     }
     

    NOTE: It is possible to use non thread-safe script engines with templating libraries not designed for concurrency, like Handlebars or React running on Nashorn, by setting the sharedEngine property to false.

    Since:
    4.2
    Author:
    Sebastien Deleuze
    See Also:
    ScriptTemplateView