Spring MVC

The jtwig-spring project includes implementations of Spring View and ViewResolver, allowing one to integrate Jtwig with Spring MVC.

copy
@Configuration
@EnableWebMvc
public class WebConfig {
    @Bean
    public ViewResolver viewResolver () {
        JtwigViewResolver viewResolver = new JtwigViewResolver();
        viewResolver.setPrefix("web:/WEB-INF/templates/");
        viewResolver.setSuffix(".twig.html");
        return viewResolver;
    }
}

The example above defines the ViewResolver bean used by Spring MVC to render a given view. The example shown here can be found in jtwig-examples.

Integration

Integration of Jtwig Spring in your project will depend on the dependency management mechanism being used. Also, you will need to make sure jcenter is part of your repository list. The most recent version is 5.86.1.RELEASE.


Gradle

copy
repositories {
    jcenter()
}

dependencies {
    compile 'org.jtwig:jtwig-spring:5.86.1.RELEASE'
}

Maven

copy

    
        bintray
        https://jcenter.bintray.com/
    



    
        org.jtwig
        jtwig-spring
        5.86.1.RELEASE